Open Huangqye opened 2 years ago
there is a while loop, inside that while loop was setted far as i see :)
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?
first loop: fiber.child = newFiber, prevFiber = newFiber . fiber -> child -> newFiber; next loop: prevFiber.sibling = nextNewFiber , fiber -> child -> newFiber -> sibling ->nextNewFiber
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
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.