-
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
Under a feature flag, start setting up "Strict Mode" prefix for warnings. #13109
Closed
Conversation
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
**what is the change?:** TDD - we add a failing test and then make it pass. This test will verify that any warning fired in strict mode gets the prefix 'strict mode warning'. **why make this change?:** We want all warnings in strict mode to have this prefix so that we can use it to configure our warning handler internally at Facebook, so that no warnings will be supressed in 'strict mode'. **test plan:** Ran the test, watched it fail. **issue:** internal task T30481686
**what is the change?:** - Moves 'ReactTypeOfMode' to the 'shared' directory - Uses 'ReactTypeOfMode' and 'ReactDebugCurrentFiber' to detect when we are in strict mode, allowing updating the warnings in the reconciler. **why make this change?:** We are in the process of prefixing all warnings with 'Strict Mode'. **test plan:** Run unit tests. **issue:** Internal task https://our.intern.facebook.com/intern/tasks/?t=30481686
**what is the change?:** see title **why make this change?:** We are going to change warning behavior, better to have a feature flag around this chnage in order to allow working on it incrementally and also allow controlled release of the change. **test plan:** Will test this in a follow-up diff. **issue:** internal task https://our.intern.facebook.com/intern/tasks/?t=30481686
**what is the change?:** See title **why make this change?:** We need this in many of our packages, and some were already requiring it using the full path. Let's just move it to 'shared'. **test plan:** Ran build and tests. **issue:** Internal task T30481686
See PR for more full description of this. **test plan:** Updated unit tests, they are passing **issue:** Internal task T30481686
gaearon
reviewed
Jun 25, 2018
PropTypes = require('prop-types'); | ||
}); | ||
|
||
xit('should should prefix any warning with "Strict Mode Warning: "', () => { |
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.
Intentionally ignored?
Details of bundled changes.Comparing: 5b3d17a...dbbb4ef react-dom
react-art
react-test-renderer
react-reconciler
react-native-renderer
Generated by 🚫 dangerJS |
We did #13240 instead. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Suggestion cannot be applied right now. Please check back later.
tldr: We want to add the "Strict Mode" prefix to all warnings which fire from within a 'strict mode' component tree, so that we can whitelist those warnings in our internal warning infrastructure.
This approach is not perfect, but we want to get something synced into Facebook asap to test before
<StrictMode
becomes widely used. This is an opportunity for us to clean up our current warning blacklist. Once we land this, we can filter for warnings with theStrict Mode
prefix and whitelist those.Once we figure out a strategy that we find helpful, we can start considering how to ease the pain of warnings landing in open source too.
What this does:
ReactDebugCurrentFiber
toshared
so that we can access it inside ofwarning
.warning
callsites as a proof of concept. Shows how we have to set upReactDebugCurrentFiber
if the warning is fired from the commit phase.Baz
toBaz, Foo
. The original did fire a warning sayingBaz, Foo
but because partial matches pass, it was passing even though it only saidBaz
in the test expectation.Concerns:
Adding 'Strict Mode' to warning strings is confusing, doesn't make sense, isn't helpful.
--> But we need to try something, and it may not be so bad. Hard to say how people will generally perceive it.
Changing 'Strict Mode' behavior will cause problems for people who have adopted it.
--> Except it's not widely adopted yet, so this is our change to make a little improvement.
It's a footgun to make
reactWarning
rely on the caller to have set upReactDebugCurrentFiber
to point to the right fiber.--> Probably, and we could move to passing in a flag, or just calling
ReactDebugCurrentFiber.current.mode & StrictMode
in the place where we construct the warning. But we may want to move to a different pattern of just usingconsole.error
instead of thewarning
/reactWarning
wrappers, and this moves us in that direction.This will mess with our warning logging.
--> We can do something internally to transform the warnings, removing the 'Strict Mode' prefix before they are actually logged. Or we can just leave it, since 'Strict Mode' shouldn't affect too many callsites yet.