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

Theme not applying on latest version of react-sortable-tree #31

Open
A9u opened this issue Aug 12, 2020 · 1 comment
Open

Theme not applying on latest version of react-sortable-tree #31

A9u opened this issue Aug 12, 2020 · 1 comment

Comments

@A9u
Copy link

A9u commented Aug 12, 2020

I am using the following versions :-

  • react-sortable-tree 2.8
  • react-sortable-tree-theme-file-explorer 2.0.0
  • next 9.4.4

I have used it as follows :-

const FileExplorerTheme = dynamic(() => import("react-sortable-tree-theme-file-explorer"), {
  ssr: false
});

<SortableTree
          treeData={treeData}
          onChange={handleChange}
          onMoveNode={handleMove}
          theme={FileExplorerTheme}

  />

I am getting following warning and the theme is not getting applied:-

Warning: Failed prop type: Invalid prop `theme` of type `function` supplied to `ReactSortableTree`, expected `object`.
@akhilkurnool
Copy link

This is because dynamic import are only supported for React components (vercel/next.js#13417) but FileExplorerTheme is an object.

To solve this,
const [fileTheme, setFileTheme] = useState(null);
useEffect(() => {
(function importSortableTree() {
import('react-sortable-tree-theme-file-explorer').then((obj) => {
setFileTheme(obj.default);
})
})();
}, [])

And use the fileTheme object

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

2 participants