-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Add feature flag to disable Fiber-only features #8757
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
Conversation
| SynchronousPriority : | ||
| LowPriority; | ||
| let priorityContext : PriorityLevel = | ||
| (useSyncScheduling || ReactFeatureFlags.disableNewFiberFeatures) ? |
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'm fine leaving this as before too – either way.
| updateContainer(element : ReactNodeList, container : OpaqueNode, parentComponent : ?ReactComponent<any, any, any>, callback: ?Function) : void { | ||
| invariant( | ||
| !ReactFeatureFlags.disableNewFiberFeatures || isValidElement(element), | ||
| 'render(): Invalid component element.' |
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.
Can you make sure null/false works? And we might as well use the old error message:
invariant(
inst === null ||
inst === false ||
React.isValidElement(inst),
'%s(...): A valid React element (or null) must be returned. You may have ' +
'returned undefined, an array or some other invalid object.',
Component.displayName || Component.name || 'Component'
);
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 think that's the message for when you return a non-element in a composite component. The one for top-level is here: https://github.com/facebook/react/blob/master/src/renderers/dom/stack/client/ReactMount.js#L439
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.
Ahh yes sorry.
|
|
||
| if (__DEV__) { | ||
| const Component = returnFiber.type; | ||
| 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.
Oops this should be an invariant
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.
Well huh, it looks like sometimes Stack warns and sometimes it's an invariant?
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.
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.
Occasionally we do that intentionally too if the warning gives a better stack.
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.
Haha didn't see that PR, sorry Dan! I'll rebase on top
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.
Occasionally we do that intentionally too if the warning gives a better stack.
Yep, but isn’t the case there. (Both stacks are internal and roughly in the same place.) I’m not sure what happened but I think there was some confusion during #6008 since it started as a different warning, and instead of getting removed, was changed to the same message as an invariant immediately after it.
I'll rebase on top
You probably only want da3dc03, 243d245, 2646272.
I haven't looked at your PR yet but you might want to do 8c4b2a6 and 5643a2c differently.
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'll cherry-pick everything except the last commit, in favor of the way I did it here, for the reason Sebastian gave here: #8648 (comment)
We have one for arrays but it is going to become Stack-specific.
This test is identical to "should warn when stateless component returns array" earlier. It was moved from another file in facebook#5884 so it likely survived by accident.
We have an invariant that checks the same case right afterwards. The warning was originally added in facebook#5884 with a distinct wording. However it was later changed to the same wording as the invariant in facebook#6008. I don't see why we would want to have both since they're saying the same thing and with (almost) the same internal stack.
We'll enable this in www in case we need to roll back to Stack.
Except for portals, which we use in some places.
Consider deprecating this in the future.
| }); | ||
|
|
||
| describe('disableNewFiberFeatures', () => { | ||
| var ReactFeatureFlags = require('ReactFeatureFlags'); |
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.
You could change var to const
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're already pretty inconsistent throughout the codebase :D One day we'll go through and clean this up
| var { isValidElement } = require('ReactElement'); | ||
| var invariant = require('invariant'); | ||
| var ReactFeatureFlags = require('ReactFeatureFlags'); | ||
|
|
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.
You can change those to import instead of require
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.
Actually, not all our tooling works with ES6 imports yet so we can't. require() works fine for us for now.
566f8d4 to
ca3497a
Compare
Moved the top-level check to ReactChildFiber like the other ones
Fixes the case where there's an uncaught error and the root unmounts. We implement this by rendering the root as if its child is null. Null is not usually allowed at the top level, so we need to special case it.
ca3497a to
9459bad
Compare
Disables Fiber-only render return types