Skip to content

Conversation

@mihaip
Copy link
Contributor

@mihaip mihaip commented Mar 17, 2015

Makes it easier to find the callsite that needs to be fixed.

Builds on the warning message added by #2726

Makes it easier to find the callsite that needs to be fixed.
@sophiebits
Copy link
Collaborator

Looks great – thanks!

sophiebits added a commit that referenced this pull request Mar 17, 2015
Include the owner name when warning about createElement(null/undefined).
@sophiebits sophiebits merged commit 5d9b228 into facebook:master Mar 17, 2015
@sophiebits
Copy link
Collaborator

(If you have a repro case, you should also be able to turn on break-on-exception in the debugger and inspect the stack trace to show you the culprit.)

@mihaip
Copy link
Contributor Author

mihaip commented Mar 17, 2015

At least in 0.12 with the batched updates strategy that we use, the stack when the exception is thrown only has our main application entry point in it, not the immediate owner's render() method, so it's not immediately useful:

instantiateReactComponent                                   @react-with-addons.js:18590
ReactMultiChild.Mixin.mountChildren                         @react-with-addons.js:12389
ReactDOMComponent.Mixin._createContentMarkup                @react-with-addons.js:7810
(anonymous function)                                        @react-with-addons.js:7732
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
ReactMultiChild.Mixin.mountChildren                         @react-with-addons.js:12393
ReactDOMComponent.Mixin._createContentMarkup                @react-with-addons.js:7810
(anonymous function)                                        @react-with-addons.js:7732
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
ReactMultiChild.Mixin.mountChildren                         @react-with-addons.js:12393
ReactDOMComponent.Mixin._createContentMarkup                @react-with-addons.js:7810
(anonymous function)                                        @react-with-addons.js:7732
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
(anonymous function)                                        @react-with-addons.js:6578
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
ReactMultiChild.Mixin.mountChildren                         @react-with-addons.js:12393
ReactDOMComponent.Mixin._createContentMarkup                @react-with-addons.js:7810
(anonymous function)                                        @react-with-addons.js:7732
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
(anonymous function)                                        @react-with-addons.js:6578
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
ReactMultiChild.Mixin.mountChildren                         @react-with-addons.js:12393
ReactDOMComponent.Mixin._createContentMarkup                @react-with-addons.js:7810
(anonymous function)                                        @react-with-addons.js:7732
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
ReactMultiChild.Mixin.mountChildren                         @react-with-addons.js:12393
ReactDOMComponent.Mixin._createContentMarkup                @react-with-addons.js:7810
(anonymous function)                                        @react-with-addons.js:7732
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
(anonymous function)                                        @react-with-addons.js:6578
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
(anonymous function)                                        @react-with-addons.js:6578
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
ReactMultiChild.Mixin.mountChildren                         @react-with-addons.js:12393
ReactDOMComponent.Mixin._createContentMarkup                @react-with-addons.js:7810
(anonymous function)                                        @react-with-addons.js:7732
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
(anonymous function)                                        @react-with-addons.js:6578
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
ReactMultiChild.Mixin.mountChildren                         @react-with-addons.js:12393
ReactDOMComponent.Mixin._createContentMarkup                @react-with-addons.js:7810
(anonymous function)                                        @react-with-addons.js:7732
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
ReactMultiChild.Mixin._mountChildByNameAtIndex              @react-with-addons.js:12593
ReactMultiChild.Mixin._updateChildren                       @react-with-addons.js:12498
ReactMultiChild.Mixin.updateChildren                        @react-with-addons.js:12445
ReactDOMComponent.Mixin._updateDOMChildren                  @react-with-addons.js:8007
(anonymous function)                                        @react-with-addons.js:7860
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
ReactComponent.Mixin.performUpdateIfNecessary               @react-with-addons.js:5486
ReactComponent.Mixin.receiveComponent                       @react-with-addons.js:5467
ReactDOMComponent.Mixin.receiveComponent                    @react-with-addons.js:7833
(anonymous function)                                        @react-with-addons.js:6959
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
ReactCompositeComponentMixin._performComponentUpdate        @react-with-addons.js:6901
ReactCompositeComponentMixin.performUpdateIfNecessary       @react-with-addons.js:6844
runBatchedUpdates                                           @react-with-addons.js:15162
Mixin.perform                                               @react-with-addons.js:16896
Mixin.perform                                               @react-with-addons.js:16896
assign.perform                                              @react-with-addons.js:15108
(anonymous function)                                        @react-with-addons.js:15187
ReactPerf.measure.wrapper                                   @react-with-addons.js:12934
Mixin.closeAll                                              @react-with-addons.js:16969
Mixin.perform                                               @react-with-addons.js:16910
ReactDefaultBatchingStrategy.batchedUpdates                 @react-with-addons.js:9142
enqueueUpdate                                               @react-with-addons.js:15229
ReactCompositeComponentMixin.replaceState                   @react-with-addons.js:6672
ReactCompositeComponentMixin.setState                       @react-with-addons.js:6644
desktop.Root.React.createClass.setNavigationState           @app.jsx:508
<...>

You can use element._owner.constructor.displayName in the console at that point, but it's a bit tedious to do every time.

@sophiebits
Copy link
Collaborator

That's true, but you can put a breakpoint where the console.warn call is. If you turn on "Pause on Uncaught Exceptions" then this line should also put you in the debugger:

throw new Error(message);

We should add a page on the React site somewhere explaining this.

@mihaip
Copy link
Contributor Author

mihaip commented Mar 17, 2015

Neat, thanks for the tip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants