Fix <FileInput>
triggers onChange
twice with latest version of react-dropzone
#10402
+20
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Fix #10401
Analysis
The issue only happens after upgrading
react-dropzone
to the latest version (14.3.5 at the time of writing). Version 14.2.3 does not show the issue.At first I thought it seemed like a regression from the
react-dropzone
lib, but on second thought, I think we should not forward theonChange
prop to the wrapping<Labeled>
anyways. We should only callonChange
ourselves, to make sure it's always fed with aFile
object or array.Solution
Exclude the
onChange
prop from the...rest
parameters.How To Test
Locally update the
react-dropzone
version:yarn up react-dropzone
.Then, run one of the following stories, and make sure they only trigger
onChange
once, with either aFile
object or array.Additional Checks
master
for a bugfix, ornext
for a featureAlso, please make sure to read the contributing guidelines.