Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. #34

Open
cha0s opened this issue Jan 24, 2021 · 0 comments

Comments

@cha0s
Copy link

cha0s commented Jan 24, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant