This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As the title says. This adds component stacks to all warnings except the ones where a package doesn't have peer or dep on React (such as react-is). Concretely, we switch over from warningWithoutStack to warning, and from lowPriorityWarningWithoutStack to lowPriorityWarning, wherever possible. Tests are adjusted accordingly.
There are three reasons for this.
Stacks are generally useful. More and consistent is better.
We want to move towards just writing console.error and console.warn in the source code, and having a Babel plugin call the wrapper with extra logic. So it's inconvenient to have this distinction.
Even for warnings that don't currently have stacks, they're actually already being added by React DevTools anyway. So the distinction hasn't mattered for a while.
What if the stack is misleading or not concrete enough? For example, maybe we have a better stack we want to pass. We do the same thing DevTools does in that case. If the last argument already looks like a component stack, we don't append an extra one.
Notably, this adds component stacks to SSR hydration mismatch warnings. They can still sometimes be misleading but it's better than nothing.
Some tests still have {withoutStack: true}. This is not because we can't emit them, but because in those particular tests we're just not inside of a tree. So we're keeping the assertion mechanism for that to avoid regressions.
In a follow-up, I will codemod to console.error / console.warn calls and a Babel plugin for the wrappers. This will also allow us to choose the right version of the wrapper depending on whether a package depends on React or not.
There's a very minor bundle size for non-React-using entry points increase due to more code paths pulling in the glue code that's only used in DEV. I'll fix that in a follow up that does this at the build time level.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
As the title says. This adds component stacks to all warnings except the ones where a package doesn't have peer or dep on React (such as
react-is
). Concretely, we switch over fromwarningWithoutStack
towarning
, and fromlowPriorityWarningWithoutStack
tolowPriorityWarning
, wherever possible. Tests are adjusted accordingly.There are three reasons for this.
console.error
andconsole.warn
in the source code, and having a Babel plugin call the wrapper with extra logic. So it's inconvenient to have this distinction.What if the stack is misleading or not concrete enough? For example, maybe we have a better stack we want to pass. We do the same thing DevTools does in that case. If the last argument already looks like a component stack, we don't append an extra one.
Notably, this adds component stacks to SSR hydration mismatch warnings. They can still sometimes be misleading but it's better than nothing.
Some tests still have
{withoutStack: true}
. This is not because we can't emit them, but because in those particular tests we're just not inside of a tree. So we're keeping the assertion mechanism for that to avoid regressions.In a follow-up, I will codemod to
console.error
/console.warn
calls and a Babel plugin for the wrappers. This will also allow us to choose the right version of the wrapper depending on whether a package depends on React or not.