-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Can we locate the line number when react makes a warning like this "Unknown DOM property class. Did you mean className?" #6062
Comments
Yes, it is on my todo list. |
I'd like to take a crack at this @jimfb. What do you imagine the warning is like, full filename/line number in the warning, component name,...? |
@mxstbr Honestly, this probably isn't the greatest first bug, until I first blaze the trail by providing an example that you can replicate. The desired output would be something like You're welcomed to take a stab at it, but just know that you're probably in for a rough time in terms of a code review. To get an idea of the structure, you will need to look at #5590. You will want to emit an event when you start processing the element**, an event when you do an operation (I think that event already exists), and an event when you finish processing the element. Then your devtool can grab the __source off the element (after enabling react-jsx-source) and use that to display the file/line information as part of the error. ** At least, that would be my first approach. An alternate approach is to process the element by replicating the control logic that detects invalid props, but that feels sucky because it relies on two totally separate code paths having the same behavior and never getting out of sync. I'm not sure which approach would ultimately pan out as preferred. |
Why do I need three separate events, I thought about using |
@mxstbr |
Fair enough, makes sense. I'll leave this to you then – if you have anything to do that might be a better first bug, ping me! |
@mxstbr We have a whole list of recommended ones here: https://github.com/facebook/react/labels/good%20first%20bug |
…6398) * New approach for 6062 fix : Show source line number on unknown property warning * WIP: ReactDebugToolEventForwarderDevTool * Update event signature to debugID * Trigger events in ReactDOMComponent * Renamed to onMountDOMComponent; passing in element directly * Added debugID; updated simple test * Added test for multi-div JSX to ref exact line * Added test for composite component
…warning (facebook#6398) * New approach for 6062 fix : Show source line number on unknown property warning * WIP: ReactDebugToolEventForwarderDevTool * Update event signature to debugID * Trigger events in ReactDOMComponent * Renamed to onMountDOMComponent; passing in element directly * Added debugID; updated simple test * Added test for multi-div JSX to ref exact line * Added test for composite component (cherry picked from commit 7cf61db)
…6398) * New approach for 6062 fix : Show source line number on unknown property warning * WIP: ReactDebugToolEventForwarderDevTool * Update event signature to debugID * Trigger events in ReactDOMComponent * Renamed to onMountDOMComponent; passing in element directly * Added debugID; updated simple test * Added test for multi-div JSX to ref exact line * Added test for composite component (cherry picked from commit 7cf61db)
We do have the line numbers for this now if you enable this transform in development. It's already included by default with Create React App. |
Just tried out "How to display line numbers in React render errors?" - The answer to that question should be in every React beginner tutorial, if not shown in the error message itself! |
Well, we do recommend using Create React App in beginner tutorials, including those we have on our own website. |
Can we locate the line number when react makes a warning like this "Unknown DOM property class. Did you mean className?"
There is no hint about which code made this warning.
The text was updated successfully, but these errors were encountered: