JSerZANP / jser.dev-comment

1 stars 0 forks source link

2023-07-18-how-react-rerenders/ #11

Open utterances-bot opened 5 months ago

utterances-bot commented 5 months ago

How does React re-render internally?

If updates are triggered after mount, React re-renders with minimum DOM updates after diffing 2 versions of Fiber Tree.

https://jser.dev/2023-07-18-how-react-rerenders/

wk180 commented 5 months ago

at 2.4, why use cloneChildFibers(). not directly retrun workInprogress.child?

mattstyles64 commented 4 months ago

“So for

,updateSlot() successfully reused 3 children, except the 4th one because current is span but we want b, thus fiber of span is created from scratch and fiber of b is deleted by deleteChild(). The newly created span is marked by placeChild().”

  • shouldn’t this be the other way around, as we’re deleting span and creating b in the update?
JSerZANP commented 4 months ago

@mattstyles64 thanks for pointing it out, this is clearly a mistake

JSerZANP commented 4 months ago

@wk180 because we need to create new fiber tree?