-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Add warnings on incorrect casing of event handler properties #3548
Comments
Good idea, thanks. |
That would be useful - sounds like the kind of thing that a lot of people would be caught out by. So this should apply to all I am not too familiar with React's internal architecture when it comes to the event-side of things, so let me know if I am not making any sense :) |
I think we only need this for DOM components (at least for now) - we attach the listeners here: https://github.com/facebook/react/blob/master/src/browser/ui/ReactDOMComponent.js#L272-L274 (we also do it later in |
This comes up fairly often in our training sessions, most often because someone uses @bloodyowl Looks like you've got a good handle on it. Did you make a PR? |
@mjackson the remaining question is just this: should we only warn for any event name with the right letters but with wrong case anywhere or just full-lowercase event names |
@bloodyowl I would prefer the first option. Since React seems to have a whitelist of valid attributes, it seems like it would be easy to project a "yellow list" of warnings by lowercasing the whitelist. |
Fixes facebook#3548. Warns on properties that are case-insensitive matches for registered event names (e.g. "onclick" instead of "onClick").
Fixes facebook#3548. Warns on properties that are case-insensitive matches for registered event names (e.g. "onclick" instead of "onClick").
Fixes facebook#3548. Warns on properties that are case-insensitive matches for registered event names (e.g. "onclick" instead of "onClick").
Fixes facebook#3548. Warns on properties that are case-insensitive matches for registered event names (e.g. "onclick" instead of "onClick").
Fixes facebook#3548. Warns on properties that are case-insensitive matches for registered event names (e.g. "onclick" instead of "onClick").
Hi,
React currently warns about incorrect casing of properties like
tabIndex
.However, it doesn't warn about this problem on event handlers, like
onKeyDown
.Being used to the "html way" of writing those attributes, I often wrote something like
onKeydown
. Sadly, attached event handlers were not called, but I didn't get any warning from React, and it took me quite some time to find my mistake.You can see an example here: http://jsfiddle.net/oj5eec84/.
Just focus on an element, and try to press a key.
The text was updated successfully, but these errors were encountered: