question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onChange event fire on component mount

See original GitHub issue

Bug 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:

  1. Go to ‘https://codesandbox.io/s/focused-bogdan-nqnxb?file=/src/App.js
  2. 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:open
  • Created 3 years ago
  • Reactions:8
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
vutpovcommented, Jan 22, 2021

@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.

1reaction
deepalcommented, Oct 25, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found