-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Include component stack in invariants #11619
Comments
I handled a similar issue #11208 before. Could I try this one? I'll try to find what these 'invariants' are. |
react/packages/react-dom/src/client/ReactDOM.js Lines 657 to 710 in 7d27851
Using the code from my previous issue: var {getCurrentFiberStackAddendum} = require('ReactDebugCurrentFiber');
invariant(
isValidContainer(container),
'Target container is not a DOM element.%s',
getCurrentFiberStackAddendum() || ''
); Would I also want to add the |
This is top level rendering so component stack wouldn't be useful there (you're not inside a component). I was thinking about these: react/packages/react-reconciler/src/ReactChildFiber.js Lines 162 to 164 in 7d27851
react/packages/react-reconciler/src/ReactFiber.js Lines 342 to 346 in 7d27851
|
Okay sweet. I'm down to implement the component stack in each of these. What other files should I implement this change in? Is there an easy way to determine which are inside a component? Should I implement the component stack in every |
Look at what the message says. Look at examples of this invariant in tests. See if it's something that happens inside a component or not. |
Gotcha. I noticed some invariants already have the component stack on the __DEV__ addendum (Lines 157 and 168): react/packages/react-reconciler/src/ReactChildFiber.js Lines 153 to 171 in 7d27851
Should I remove it from the __DEV__ and put it directly on the invariant: invariant(
false,
'Objects are not valid as a React child (found: %s).%s.%s',
Object.prototype.toString.call(newChild) === '[object Object]'
? 'object with keys {' + Object.keys(newChild).join(', ') + '}'
: newChild,
addendum,
getCurrentFiberStackAddendum() || '',
); |
That sounds reasonable. |
Currently |
Yeah that makes sense. I think our integrations like CRA error box don't currently surface that but it's something that can be addressed in them. |
IIRC we didn't include it because it was DEV-only. But it's not anymore.
Maybe let's start including it?
Errors are often more prominent than warnings, and it would be great to have this info in both.
The text was updated successfully, but these errors were encountered: