File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 11import { useEffect , useState } from "react" ;
22import { TreeConfig , TreeState , createTree } from "@headless-tree/core" ;
33
4+ let mounted = false ;
5+
46export const useTree = < T , > ( config : TreeConfig < T > ) => {
57 const [ tree ] = useState ( ( ) => ( { current : createTree ( config ) } ) ) ;
68 const [ state , setState ] = useState < Partial < TreeState < T > > > ( ( ) =>
79 tree . current . getState ( ) ,
810 ) ;
911
1012 useEffect ( ( ) => {
11- ( tree . current as any ) . setMounted ( true ) ;
13+ // (tree.current as any).setMounted(true);
1214 tree . current . rebuildTree ( ) ;
13- return ( ) => {
14- // eslint-disable-next-line react-hooks/exhaustive-deps
15- ( tree . current as any ) . setMounted ( false ) ;
16- } ;
15+ setInterval ( ( ) => {
16+ mounted = ! mounted ;
17+ ( tree . current as any ) . setMounted ( mounted ) ;
18+ console . log ( { mounted } ) ;
19+ } , 3000 ) ;
20+ // return () => {
21+ // // eslint-disable-next-line react-hooks/exhaustive-deps
22+ // (tree.current as any).setMounted(false);
23+ // };
1724 } , [ tree ] ) ;
1825
1926 tree . current . setConfig ( ( prev ) => ( {
You can’t perform that action at this time.
0 commit comments