Skip to content
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

Fix mount and unmount warnings in Fiber #10056

Merged
merged 2 commits into from
Jun 28, 2017

Conversation

sebmarkbage
Copy link
Collaborator

Warn if unmounting a non-container. Warn if mounting into a container where the first child isn't the "root".

@gaearon
Copy link
Collaborator

gaearon commented Jun 27, 2017

Flow failing.

@sebmarkbage sebmarkbage force-pushed the fixmountwarnings branch 2 times, most recently from c765469 to 37a0139 Compare June 27, 2017 22:37
@sebmarkbage
Copy link
Collaborator Author

Fixed. The missing brand check for nodeType is annoying.

false,
'render(): Target node has markup rendered by React, but there ' +
'are unrelated nodes as well. This is most commonly caused by ' +
'white-space inserted around server-rendered markup.',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: whitespace is usually written as a single word?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it's just an old message.

while (container.lastChild) {
container.removeChild(container.lastChild);
let rootSibling = container.lastChild;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: we read it twice here, can we avoid that?
Supernit: I see two spaces before =

Copy link
Collaborator Author

@sebmarkbage sebmarkbage Jun 27, 2017

Choose a reason for hiding this comment

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

Using the variable to avoid reading it twice yields slightly larger code in prod. :)

Fixed the nit. Forgot prettier.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh wait. I figured out another way to write it.

Copy link
Contributor

Choose a reason for hiding this comment

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

"supernit" 🤣

This triggers our non-reuse mode. This is covered by ReactMount already but
the test doesn't pass yet without also landing facebook#10026.
@sebmarkbage sebmarkbage merged commit 52a2365 into facebook:master Jun 28, 2017
// Check if the container itself is a React root node.
const isContainerReactRoot =
container.nodeType === 1 &&
isValidContainer(container.parentNode) &&
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@spicyj Should we check for a previous sibling that is a container too? To support this warning properly for comment mount points.

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.

4 participants