Conversation
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| ``` | ||
|
|
||
| <UploadButton | ||
| endpoint="mockRoute" |
There was a problem hiding this comment.
having these actually load instead of fetch failing helped reduce some impossible states we had weird paths for just to display in here
| const [uploadProgress, setUploadProgress] = useState( | ||
| $props.__internal_upload_progress ?? 0, | ||
| ); | ||
| const [files, setFiles] = useState<File[]>([]); |
There was a problem hiding this comment.
i think it makes sense for useUploadThing to control state? Especially if the getInputProps should have an onChange that sets files. Felt weird passing those in like getInputProps({ mode, files, setFiles }). By letting the hook own the state we have access to it in getInputProps for "free"
There was a problem hiding this comment.
Have to think how it's used in forms though
| let filesToUpload = pastedFiles; | ||
| setFiles((prev) => { | ||
| filesToUpload = [...prev, ...pastedFiles]; | ||
| return filesToUpload; | ||
| }); |
There was a problem hiding this comment.
This bug was fixed for dropzone in an earlier PR (#622)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
t3dotgg
left a comment
There was a problem hiding this comment.
The getInputProps bit looks great to me, hopefully that's not too hard to get up to date. Sorry for letting this slip 🙃
📦 Bundle size comparison
|
| ) => { | ||
| const [files, setFiles] = useControllableState({ | ||
| prop: opts?.files, | ||
| onChange: opts?.onFilesChange, |
There was a problem hiding this comment.
Closes #729
Note
Experimenting a bit without thinking about breaking changes, just providing the best DX. Will come back and see if I can make it backwards compat later
Changelog
useControlledStatefrom RadixUIpermittedFileInfouseDropzonesignature to take in a route config for easier integration with uploadthing file routesbytesToFileSizeas a public util for formatting filesize as strings in custom components