-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: getInputProps
#746
base: main
Are you sure you want to change the base?
feat: getInputProps
#746
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
docs/src/pages/theming.mdx
Outdated
@@ -242,6 +242,7 @@ component match your design in the exact way you want. | |||
``` | |||
|
|||
<UploadButton | |||
endpoint="mockRoute" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having these actually load instead of fetch failing helped reduce some impossible states we had weird paths for just to display in here
$props.__internal_upload_progress ?? 0, | ||
); | ||
const [files, setFiles] = useState<File[]>([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bug was fixed for dropzone in an earlier PR (#622)
Co-authored-by: Julius Marminge <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
useControlledState
from RadixUIpermittedFileInfo
useDropzone
signature to take in a route config for easier integration with uploadthing file routesbytesToFileSize
as a public util for formatting filesize as strings in custom components