import SortableTree from 'react-sortable-tree';
import theme from 'react-sortable-tree-theme-file-explorer';
const Project = ({project: {label, tree}}) => (
<div className="project">
<h2 className="project__title">{label}</h2>
<SortableTree
theme={theme}
treeData={tree}
/>
</div>
);
Gives:
Warning: React.createElement: type is invalid -- expected a string (for built-in components)
or a class/function (for composite components) but got: undefined. You likely forgot to export
your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `SortableTree`.
When I look in node_modules/react-sortable-tree/dist/index.esm.js, the default export is:
var SortableTree = function SortableTree(props) {
return React.createElement(DndProvider, {
backend: HTML5Backend
}, React.createElement(SortableTreeWithoutDndContext, props));
};
So, I:
> console.log(DndProvider);
undefined
A little more inspection:
$ node
Welcome to Node.js v14.15.1.
Type ".help" for more information.
> require('react-dnd')
{
DragDropContext: [Getter],
DragDropContextProvider: [Getter],
DragLayer: [Getter],
DragSource: [Getter],
DropTarget: [Getter]
}
> require('react-dnd/package.json').version
'2.5.4'
...that's a very old version. More inspection:
> require('react-sortable-tree-theme-file-explorer/package.json').dependencies['react-dnd'];
'2.5.4'
> require('react-sortable-tree-theme-file-explorer/package.json').version;
'2.0.0'
It appears this project is badly out of date and completely broken.