| 83 | const RecursiveContext = createContext<(nodeId: number, parentsPath: number[]) => void>(() => {}) |
| 84 | |
| 85 | const Recursive: Component = props => { |
| 86 | const [data, setData] = createStore<NodeType[]>([ |
| 87 | { |
| 88 | id: 0, |
| 89 | children: [ |
| 90 | {id: 1, children: [{id: 2, children: []}]}, |
| 91 | {id: 3, children: []}, |
| 92 | ], |
| 93 | }, |
| 94 | ]) |
| 95 | |
| 96 | const addNode = (nodeId: number, parentsPath: number[]) => { |
| 97 | setData( |
| 98 | // @ts-ignore |
| 99 | ...genNodePath({nodeId, parentsPath}), |
| 100 | (children: any) => [...children, {id: ++id, children: []}], |
| 101 | ) |
| 102 | } |
| 103 | |
| 104 | return ( |
| 105 | <RecursiveContext.Provider value={addNode}> |
| 106 | <For each={data}>{page => <Node {...page} />}</For> |
| 107 | </RecursiveContext.Provider> |
| 108 | ) |
| 109 | } |
| 110 | |
| 111 | export default Recursive |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…