[Fiber] Fix TestUtils edge cases#8257
Conversation
| while (root.return) { | ||
| root = root.return; | ||
| } | ||
| var isRootCurrent = root.tag === HostContainer && root.stateNode.current === root; |
There was a problem hiding this comment.
I'm not sure if this is a good way to tell that we're in a current tree. Any pitfalls?
There was a problem hiding this comment.
I'm facing the same problem in the PR I'm working on.
|
👍 but let's decide (or clarify) the established way to determine whether a fiber is current |
|
Hmm, I don't think following the |
|
What's the right way to get the current version of a given Fiber? I tried looking at |
|
I think |
|
So maybe function getCurrentFiber(fiber : Fiber): Fiber | null {
if (isFiberMounted(fiber)) {
return fiber;
} else if (fiber.alternate && isFiberMounted(fiber.alternate)) {
return fiber.alternate;
} else {
return null;
}
} |
|
I tried this but |
|
Huh interesting. Maybe what you did is correct then. Can't say I fully understand, though. Could you put your solution into |
|
Actually I think I understand now. Your solution is correct 👍 |
|
Haha now I'm not sure if it's correct. 😄 |
|
I think #7344 (comment) doesn't apply because I don't care if either node on the path is current or not. I only care about the root node for which I can find it out. I also care that if a node's root is current, it follows that the node is current. Does this assumption always hold? |
|
I think it does because the |
* Add more reactComponentExpect tests * Implement reactComponentExpect in Fiber
359906f to
3bcc173
Compare
|
OK, let's do it and if it's broken then add a breaking test. |
* Add more reactComponentExpect tests * Implement reactComponentExpect in Fiber
The rest of TestUtils failures are now all Simulate related.