onChange event fire on component mount
See original GitHub issueBug Report
Describe the bug
I’m trying to fire some functions on the onChange event, which from what I understand from the document only fire when files change but somehow it also fires when component mount. Is there something I’m missing here?
Steps to reproduce
Steps to reproduce the behavior:
- Go to ‘https://codesandbox.io/s/focused-bogdan-nqnxb?file=/src/App.js’
- See console.log
Expected behavior
Codes inside the onChange event should not run when component mount or when initial files are provided.
Versions
@material-ui/core
version: [e.g. 4.11]material-ui-dropzone
version: [e.g. 3.3.1]
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Can I call an onChange event from componentDidMount
I would change the code to something like this: handleChange(event) { this.handleValue(event.target.value); } handleValue(value) { let ...
Read more >Does an onChange event fire before or after state is set?
I have programmed an onChange event to conditionally display the dropdown based on two criteria: whether there is any user value currently ...
Read more >Onchange event on the field fires on the page load
Lightning components that contain the input field(s) with onchange event, especially on picklist Field, can cause to fire an additional onchange event on...
Read more >Simulate React On-Change On Controlled Components
The input logic in React now dedupe's change events so they don't fire more than once per value. It listens for both browser...
Read more >react input onchange doesn't work - You.com | The AI Search ...
When React re-renders your component frequently, they're going to retrigger the Pdindex() function. Because you've put the state inside that function, you ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tier42-mike let say that I try to load some files from the backend, and then send the last dropped file to the backend via onChange. It wouldn’t make sense to fire the onChange right away when the intialFiles props is provided.
Is there any update on this? I’m experiencing the same annoying issue. If someone knows at least a workaround, that would be really appreciated.