(store: FileSystemStore, folderPath: string)
| 299 | * Watches for changes to child nodes of a specific folder |
| 300 | */ |
| 301 | export function useFolderChildren(store: FileSystemStore, folderPath: string) { |
| 302 | const [children, setChildren] = useState<FileNode[]>(() => store.getChildrenByPath(folderPath)); |
| 303 | |
| 304 | useEffect(() => { |
| 305 | setChildren(store.getChildrenByPath(folderPath)); |
| 306 | |
| 307 | const unsubscribe = store.subscribe((event: FileSystemEvent) => { |
| 308 | if ( |
| 309 | event.type === 'node_added' || |
| 310 | event.type === 'node_removed' || |
| 311 | event.type === 'store_reset' |
| 312 | ) { |
| 313 | setChildren(store.getChildrenByPath(folderPath)); |
| 314 | } |
| 315 | }); |
| 316 | |
| 317 | return unsubscribe; |
| 318 | }, [store, folderPath]); |
| 319 | |
| 320 | return children; |
| 321 | } |
| 322 | |
| 323 | export default useFileSystem; |
nothing calls this directly
no test coverage detected