-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
Conversation
Flow failing. |
c765469
to
37a0139
Compare
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.', |
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.
Nit: whitespace is usually written as a single word?
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 guess it's just an old message.
while (container.lastChild) { | ||
container.removeChild(container.lastChild); | ||
let rootSibling = container.lastChild; |
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.
Nit: we read it twice here, can we avoid that?
Supernit: I see two spaces before =
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.
Using the variable to avoid reading it twice yields slightly larger code in prod. :)
Fixed the nit. Forgot prettier.
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.
Oh wait. I figured out another way to write it.
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.
"supernit" 🤣
37a0139
to
bac9e3c
Compare
This triggers our non-reuse mode. This is covered by ReactMount already but the test doesn't pass yet without also landing facebook#10026.
bac9e3c
to
bbd97bd
Compare
// Check if the container itself is a React root node. | ||
const isContainerReactRoot = | ||
container.nodeType === 1 && | ||
isValidContainer(container.parentNode) && |
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.
@spicyj Should we check for a previous sibling that is a container too? To support this warning properly for comment mount points.
Warn if unmounting a non-container. Warn if mounting into a container where the first child isn't the "root".