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

I learned from 'Build Your Own React' and encountered problems in building Fiber #42

Open
Huangqye opened this issue Jul 11, 2022 · 4 comments

Comments

@Huangqye
Copy link

in step 4 Fiber, prevSibling.sibling = newFiber;, fiber is the argument and prevSibling is the variable inside the function. How does the sibling come into fiber? Thank you.

@shadowvzs
Copy link

there is a while loop, inside that while loop was setted far as i see :)

@Huangqye
Copy link
Author

there is a while loop, inside that while loop was setted far as i see :)

Thank you for your reply. I really want to know how fiber can bind the sibling?

@Akarinx
Copy link

Akarinx commented Jan 11, 2023

first loop: fiber.child = newFiber, prevFiber = newFiber . fiber -> child -> newFiber;
next loop: prevFiber.sibling = nextNewFiber , fiber -> child -> newFiber -> sibling ->nextNewFiber

@electroluxcode
Copy link

electroluxcode commented Mar 13, 2023

To be honest, I don't think the author's approach is easy to understand. My treatment of sibling is
if (i == 0) { fiber.children = newFiber } else { fiber.sibling = newFiber }
Specific can refer to:https://codepen.io/yilaikesi/pen/xxaYqLQ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants