-
Notifications
You must be signed in to change notification settings - Fork 49.8k
[Fiber] disableNewFiberFeatures bugfix: host component children arrays #8797
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
Changes from 1 commit
16956ed
1ac6be2
5c4362d
c0e5df6
645ad6d
ba1d382
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This exposed a few more cases that I missed.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -75,7 +75,6 @@ const { | |||
| NoEffect, | ||||
| Placement, | ||||
| Deletion, | ||||
| Err, | ||||
| } = ReactTypeOfSideEffect; | ||||
|
|
||||
| function coerceRef(current: ?Fiber, element: ReactElement) { | ||||
|
|
@@ -1127,41 +1126,40 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) { | |||
| } | ||||
| } | ||||
|
|
||||
| if (returnFiber.tag === HostRoot) { | ||||
| // Top-level only accepts elements or portals | ||||
| invariant( | ||||
| // If the root has an error effect, this is an intentional unmount. | ||||
| // Don't throw an error. | ||||
| returnFiber.effectTag & Err, | ||||
| 'render(): Invalid component element.' | ||||
| ); | ||||
| } else { | ||||
| switch (returnFiber.tag) { | ||||
| case ClassComponent: { | ||||
| if (__DEV__) { | ||||
| const instance = returnFiber.stateNode; | ||||
| if (instance.render._isMockFunction) { | ||||
| // We allow auto-mocks to proceed as if they're | ||||
| // returning null. | ||||
| break; | ||||
| } | ||||
| switch (returnFiber.tag) { | ||||
| case ClassComponent: { | ||||
| if (__DEV__) { | ||||
| const instance = returnFiber.stateNode; | ||||
| if (instance.render._isMockFunction) { | ||||
| // We allow auto-mocks to proceed as if they're | ||||
| // returning null. | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What you're really saying here is that they're allowed to return anything (including strings, arrays etc.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Looks like Stack only accepts
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||||
| break; | ||||
| } | ||||
| } | ||||
| // Intentionally fall through to the next case, which handles both | ||||
| // functions and classes | ||||
| // eslint-disable-next-lined no-fallthrough | ||||
| case FunctionalComponent: { | ||||
| // Composites accept elements, portals, null, or false | ||||
| const Component = returnFiber.type; | ||||
| invariant( | ||||
| newChild === null || newChild === false, | ||||
| '%s.render(): 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' | ||||
| ); | ||||
| } | ||||
| } | ||||
| // Intentionally fall through to the next case, which handles both | ||||
| // functions and classes | ||||
| // eslint-disable-next-lined no-fallthrough | ||||
| case FunctionalComponent: { | ||||
| // Composites accept elements, portals, null, or false | ||||
| const Component = returnFiber.type; | ||||
| invariant( | ||||
| newChild === null || newChild === false, | ||||
| '%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' | ||||
| ); | ||||
| } | ||||
| } | ||||
|
|
||||
| if (typeof newChild === 'string' || typeof newChild === 'number') { | ||||
| return placeSingleChild(reconcileSingleTextNode( | ||||
| returnFiber, | ||||
| currentFirstChild, | ||||
| '' + newChild, | ||||
| priority | ||||
| )); | ||||
| } | ||||
|
|
||||
| if (isArray(newChild)) { | ||||
|
|
||||
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.
Seems unnecessary to fork this whole function now. Can't you just add this conditional down below behind a smaller
if (ReactFeatureFlags.disableNewFiberFeatures) {instead of forking the whole function?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.
Forking the entire function was the only way I could get it down to a single check. But you're right that there's a lot of overlap and it's weird to fork the entire thing. I split it out into three checks instead.