-
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
Fix for #6062 : Show source line number on unknown property warning #6398
Conversation
@@ -651,6 +652,9 @@ ReactDOMComponent.Mixin = { | |||
markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue); | |||
} | |||
} else { | |||
if (__DEV__) { | |||
ReactDOMInstrumentation.debugTool.onCreateMarkupForProperty(propKey, propValue, this._currentElement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is the main one that concerns me. It seems like this call should be inside createMarkupForProperty
such that it gets invoked whenever anyone calls it will get the onCreateMarkupForProperty
event. However, we should not be passing the element to createMarkupForProperty
.
Thus, why this PR is difficult, thus my comments in #6062 (comment) and #6062 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't realize that operation was called directly. I've another
approach in mind as well, I'll try it out next week.
On Apr 1, 2016 6:35 PM, "Jim" [email protected] wrote:
In src/renderers/dom/shared/ReactDOMComponent.js
#6398 (comment):@@ -651,6 +652,9 @@ ReactDOMComponent.Mixin = {
markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue);
}
} else {
if (**DEV**) {
ReactDOMInstrumentation.debugTool.onCreateMarkupForProperty(propKey, propValue, this._currentElement);
This line is the main one that concerns me. It seems like this call should
be inside createMarkupForProperty such that it gets invoked whenever
anyone calls it will get the onCreateMarkupForProperty event. However, we
should not be passing the element to createMarkupForProperty.Thus, why this PR is difficult, thus my comments in #6062 (comment)
#6062 (comment)
and #6062 (comment)
#6062 (comment)—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/facebook/react/pull/6398/files/295b048adf2a1de62d2572c179da584bccfc7cb1#r58281313
@troydemonbreun updated the pull request. |
1 similar comment
@troydemonbreun updated the pull request. |
@troydemonbreun updated the pull request. |
@jimfb What about this approach? Thanks for your time. |
@troydemonbreun Yes, this is the approach that I had in mind. However, you're going to want to save the source when a component is rendering (ie. as oppose to We will need unit tests for all the various cases. Three that come to mind are:
|
728c96d
to
0012131
Compare
@troydemonbreun updated the pull request. |
@jimfb Thanks for the direction! I noticed that |
@troydemonbreun Probably |
Ping @troydemonbreun |
Sorry about the delay, my Dev VM is having problems, looks like I will |
@troydemonbreun updated the pull request. |
@jimfb Trying to grok your last piece of advice. To keep from bothering you, I've spent some time browsing the code trying to infer from current debug tool examples, etc. Do you mean to create another debug tool and I've also thought of Thanks for your time. |
@troydemonbreun updated the pull request. |
Yes, I was thinking of a
I think registration would occur in |
@troydemonbreun updated the pull request. |
@jimfb I have pushed my latest work in progress to this PR to show my progress. Thanks! |
); | ||
}; | ||
|
||
var formatSource = function(source) { | ||
return source ? `(${source.fileName.replace(/^.*[\\\/]/, '')}:${source.lineNumber})` : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally prefer string concatenation instead of template literals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have a policy on this; either is fine in my book.
The places that those elements get generated is within The places that we currently warn are: Does that make sense? Let me know if not / if you have questions that I can clarify. |
I think that makes sense. I'll dissect |
@troydemonbreun updated the pull request. |
@jimfb I've added in more tests for |
@troydemonbreun To trigger that case (with the
ReactDOM will never fire an I'm going to tentatively accept, since I think this PR makes the world incrementally better. |
@jimfb Great, thanks for all your help! I'll keep this PR as it is now functionally to keep things simple. |
@troydemonbreun Great job! Sorry that I haven’t been very responsive. |
Thanks! You have been responsive and helpful.
|
…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)
Fix for #6062
Let me know if I'm off base by using this approach.
(in trying to rebase with a merge conflict, I created commit noise, sorry)
Thanks!