-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Added note about multiple Reacts, since this error commonly implies that. #4470
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
|
@spicyj you have context on this diff. For those following along at home, we've seen a bunch of github issues where people are confused, which means it's probably confusing a bunch of people who don't report it to us. We want to point users in the right direction with a helpful/timely message. Lint failure is from a different file, unrelated to change. Should be fixed independently. |
|
(lint is some false positive thanks to build caching, cleared and retriggered - I hit it on master too) |
|
How about add a magic token in the global object. Use the token to determine whether a past React had been loaded. And then print a warning ? |
|
@maoziliang We tried that, but it ended up warning people in unit tests and we had to revert the diff (#3646). |
|
Ping. |
|
I want to criticize the too-long wording but haven't gotten around to it yet… |
|
@spicyj Comment overall or specifically my addition? |
|
Mostly it's just really long now. |
|
@jimfb An idea would be to add a property (not attribute) to React root nodes with a per-React instance random value. Then for all the various asserts that can be affected by multiple Reacts we first check whether the property of the root node of that React tree has the value we expect, if it doesn't we know there's a different instance present. |
1545575 to
4e6a1eb
Compare
|
@spicyj Better? It is now 4 lines instead of 7 lines :P. @syranide That's not a bad idea. If the root node is a web component, it might respond badly to having a random property set on it, but maybe we skip the check for web components? It's worth looking into, but not worth blocking this fix. This is a trivial mitigation that will catch the most common case. |
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.
https, period at the end of the sentence
|
Okay, I guess this is fine. Can you shorten the remove message too? (Not sure I've ever seen it though since you'd always hit the add invariant first in practice.) |
4e6a1eb to
0597654
Compare
0597654 to
e984d2b
Compare
|
@spicyj Yeah, done. Is it even possible to hit that remove path? Seems like you'd need to add the ref in order to remove it, so it would be impossible to hit. |
Added note about multiple Reacts, since this error commonly implies that.
Added note about multiple Reacts, since this error commonly implies that.