Closed TinsFox closed 1 year ago
It looks like your onClick()
function is never called. Are you sure it's hooked up correctly?
It looks like your
onClick()
function is never called. Are you sure it's hooked up correctly?
I trigger through the click event of the button. Confusingly, when I checked again just now it was working fine again! But in the afternoon, he really can't wake up the window for selecting file folders.
Seems to be fine then. Thanks!
I try the example in the edge, but it nor work. here is my edge info:
And then I code a demo like this, the console say it's supported
code
```tsx import { directoryOpen, supported } from 'browser-fs-access'; const Editor = () => { if (supported) { console.log('Using the File System Access API.'); } else { console.log('Using the fallback implementation.'); } const appendImage = (blob) => { const img = document.createElement('img'); img.src = URL.createObjectURL(blob); document.body.append(img); img.onload = img.onerror = () => URL.revokeObjectURL(img.src); }; const listDirectory = (blobs) => { let fileStructure = ''; blobs .sort((a, b) => a.webkitRelativePath.localeCompare(b)) .forEach((blob) => { // The File System Access API currently reports the `webkitRelativePath` // as empty string `''`. fileStructure += `${blob.webkitRelativePath}\n`; }); // pre.textContent += fileStructure; blobs .filter((blob) => { return blob.type.startsWith('image/'); }) .forEach((blob) => { appendImage(blob); }); }; const onClick = async () => { try { const blobs = await directoryOpen(); console.log('blobs', blobs); listDirectory(blobs); } catch (err) { console.log('err', err); if (err.name !== 'AbortError') { return console.error(err); } // console.log(ABORT_MESSAGE); } }; return ( <> > ); }; export default Editor; ```