11import React , { ReactElement , useCallback , useEffect , useState } from 'react' ;
22import { FlatList , Pressable } from 'react-native' ;
33import globalHook , { Store } from 'use-global-hook' ;
4-
5- export interface INode {
6- _internalId : string ;
7- hidden : boolean ;
8- opened : boolean ;
9- [ key : string ] : any ;
10- }
4+ import { GlobalState , INode , NodeActions } from './types' ;
115
126export interface IProps {
137 getChildrenName : ( item : INode ) => string ;
@@ -24,23 +18,6 @@ export interface IProps {
2418 keepOpenedState ?: boolean ;
2519}
2620
27- export interface IState {
28- node : INode ;
29- extraData ?: any ;
30- opened : boolean ;
31- }
32-
33- interface GlobalState {
34- nodesState : { root : boolean } ;
35- }
36-
37- interface NodeActions {
38- setOpenedNode : (
39- store : Store < GlobalState , NodeActions > ,
40- { internalId, opened } : any ,
41- ) => void ;
42- }
43-
4421const actions = {
4522 setOpenedNode : (
4623 store : Store < GlobalState , NodeActions > ,
@@ -59,7 +36,7 @@ const initialState: GlobalState = {
5936// @ts -ignore
6037const useGlobal = globalHook < GlobalState , NodeActions > ( initialState , actions ) ;
6138
62- const NodeView = React . memo (
39+ const NodeView : React . FC < IProps > = React . memo (
6340 ( {
6441 renderNode,
6542 extraData,
@@ -68,7 +45,7 @@ const NodeView = React.memo(
6845 node,
6946 onNodePressed,
7047 keepOpenedState,
71- } : IProps ) => {
48+ } ) => {
7249 const [ globalState , globalActions ] : [ any , any ] = useGlobal ( ) ;
7350
7451 const [ _node , setNode ] : [ INode , any ] = useState ( {
0 commit comments