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

ReferenceError: self is not defined #96

Open
Suriyasanjay opened this issue Jun 30, 2023 · 1 comment
Open

ReferenceError: self is not defined #96

Suriyasanjay opened this issue Jun 30, 2023 · 1 comment

Comments

@Suriyasanjay
Copy link

this my code given by the reference but shows he error

import React, { useEffect, useState } from 'react';
import FolderTree from 'react-folder-tree';

// Polyfill for the self object

const Custom = () => {
const [treeState, setTreeState] = useState(null);

const treeData = {
name: 'root [half checked and opened]',
checked: 0.5,
isOpen: true,
children: [
{ name: 'children 1 [not checked]', checked: 0 },
{
name: 'children 2 [half checked and not opened]',
checked: 0.5,
isOpen: false,
children: [
{ name: 'children 2-1 [not checked]', checked: 0 },
{ name: 'children 2-2 [checked]', checked: 1 },
],
},
],
};

useEffect(() => {
setTreeState(treeData);
}, []);

return (


{treeState && (
<FolderTree data={treeState} onChange={(state, event) => setTreeState(state)} />
)}

);
};

export default Custom;

@apollo0102
Copy link

Hi man
I think you use nextjs.

import dynamic from "next/dynamic";
const FolderTree = dynamic(() => import("react-folder-tree"), { ssr: false });

Please refer above codes.

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