Comments (9)
Hello!
Just wanted to confirm the solution mentioned above, as I was able to successfully debug the ReferenceError of 'self' not being defined within a Nextjs implementation of this module. I dynamically imported the module as @admondtamang suggested and it debugged the issue! Posted my code below just for further context. Great library @shunjizhan!
PS.. I just created a testData.js file in my root, and imported it directly from there as opposed to importing the object from the module itself, however it is probably still possible through another solution/fix that uses dynamic importing.
import React from 'react';
import dynamic from 'next/dynamic';
import { testData } from './testData';
const DynamicFileTreeImport = dynamic(() => import('react-folder-tree'), {
ssr: false, // needed to prevent warning about dynamic component
});
const DocFileTree = () => {
const onTreeStateChange = (state, event) => console.log(state, event);
return <DynamicFileTreeImport data={testData} onChange={onTreeStateChange} />;
};
export default DocFileTree;
from react-folder-tree.
Lazy loading with dynamic import or ssr false worked for me.
import dynamic from "next/dynamic";
const NavigationFolder = dynamic(() => import("./TreeFolder"), {
loading: () => <p>Loading...</p>,
});
const FolderTree = dynamic(() => import("react-folder-tree"), {
ssr: false,
});
from react-folder-tree.
@shunjizhan actually I solve a problem of mine based on your reply. Thanks a lot!
from react-folder-tree.
@shunjizhan actually I solve a problem of mine based on your reply. Thanks a lot!
do you mean @admondtamang 's reply haha? Thanks @admondtamang for the suggestion
from react-folder-tree.
thanks for pointing this out! I am not super familiar with next.js, but in later versions will probably do some research on this.
At the same time please try fork it to accommodate next.js : )
from react-folder-tree.
hello @shunjizhan, I will try to draft a PR when I have time. Just promise me you dont ignore it hehe
from react-folder-tree.
@phatNfqAsia sure! Your contribution is very welcomed, I will definitely not ignore it if it works
from react-folder-tree.
@shunjizhan oh if it done the job we can close it now, but I also recommend you convert your library to dumb components so that user can adapt it better to their usecases, currently the logic (check/uncheck, actions) is in one package and it's hard for user to customize.
from react-folder-tree.
Hi @Djcarrillo6 ,
Thanks for confirming this method works, this is definitely very helpful for people experiencing similar issue : )
I should probably add this example in the doc in the next version
from react-folder-tree.
Related Issues (20)
- Show toolbar only in clicked folders HOT 1
- The possibility of adding custom icons to add files and add folders
- Add the ability to search on the tree structure
- Remove checkbok only on files
- My hateCheckbox attribute doesn't work
- Usage with remix HOT 1
- Add support for auto selection of an item having same key/_id across the tree at different levels
- Type specification for every child HOT 1
- Cannot set properties of null (setting '_id') HOT 3
- Selection of only single child makes its parent fully checked, is there a way to make it half checked HOT 2
- How can I add new custom params when I add a file or folder.
- delete root folder HOT 2
- Delete a "branch"
- border of name edition
- edit name directly
- Specify css for each TreeNode of each folder tree
- Infinite render loop
- ReferenceError: self is not defined HOT 1
- how can i remove checkbox and add radio button imnstead of them and if this is not possible then how can i make the checkboxes like radio buttons with respect to functionality means only one selectable at a time
- Highlight Filename on Click
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-folder-tree.