-
Notifications
You must be signed in to change notification settings - Fork 48.4k
Should throw error when null or falsy values are passed as event listeners #1255
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
Comments
I'm afraid this behavior is intentional so that you can write things like onChange={isEnabled && this.handleChange}, and I don't think we're going to change this. |
this explains the falsey part but not why failing silently for null value. Passing null values as event listeners should at least be warned. |
Similarly, you could write |
Right. Have you thought about standardizing on boolean Maybe not worth breaking change, but we tripped over this a couple of times where someone changes a method name or a typo etc. |
I personally find it much weirder that |
I understand the reasoning behind keeping the events and props interface similar but this has bit me a few times on stupid typos and refactorings. React is usually very good about failing early and loudly in dev for other gotchas, and this seems like an odd oversight. IMO |
Null values for event listeners fail silently. http://jsfiddle.net/2BCLQ/1/
Falsy values for event listeners fail silently http://jsfiddle.net/2BCLQ/2/
The text was updated successfully, but these errors were encountered: