const [contents] = createResource(props.path, (path) => fetch_directory(path) ); return ( <> <Switch> <Match when={contents.loading}> <div>Loading...</div> </Match> <Match when={contents.error}> <div>Error: {contents.error}</div> </Match> <Match when={contents()}> <For each={contents()}> {(content) => ( <Switch> <Match when={content.type === "directory"}> <Directory file={content} /> </Match> <Match when={content.type}> <File file={content} /> </Match> </Switch> )} </For> </Match> </Switch> </> );
createEffect(() => { console.log(props.path); refetch(); });
export default function FileViewer() { const path = useStore(pathStore); return ( <div class="ml-1"> <p>{path()}</p> <Show when={path()}> <FolderContents path={path()} /> </Show> </div> );}