Skip to content

Conversation

@acdlite
Copy link
Collaborator

@acdlite acdlite commented Jan 12, 2017

Disables Fiber-only render return types

SynchronousPriority :
LowPriority;
let priorityContext : PriorityLevel =
(useSyncScheduling || ReactFeatureFlags.disableNewFiberFeatures) ?
Copy link
Collaborator

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.'
Copy link
Collaborator

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'
      );

Copy link
Collaborator Author

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

Copy link
Collaborator

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(
Copy link
Collaborator Author

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@gaearon gaearon Jan 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stack both warns and does an invariant with the same message. This is an artifact from some earlier refactor when this was a different warning but has since become irrelevant. See 2646272 and feel free to reuse my other commits in #8648.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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

Copy link
Collaborator

@gaearon gaearon Jan 12, 2017

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.

Copy link
Collaborator Author

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)

gaearon and others added 8 commits January 11, 2017 17:10
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.
});

describe('disableNewFiberFeatures', () => {
var ReactFeatureFlags = require('ReactFeatureFlags');
Copy link

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

Copy link
Collaborator Author

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');

Copy link

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

Copy link
Collaborator

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.

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.
@acdlite acdlite merged commit d28ac9e into facebook:master Jan 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants