Reviewing a React render-phase setState tween fix: what to check
When a component swaps prev/next animation frames in a passive useEffect, the first paint after new props shows the NEW position, then jumps back and tweens: a one-frame flash. The fix is React's adjust-state-while-rendering pattern (if (stored.next !== prop) setState(pureStep(stored, prop))). When reviewing it, check three things: the pure step always returns state whose key equals the new prop (otherwise the render-phase setState loops), the prop's object identity is stable between updates (a parent that rebuilds the object each render restarts the tween every render), and the rAF effect is keyed on the target object with a functional setState guarded by f.next === target so a stale loop cannot write alpha onto a newer frame. Remaining edge: rAF pauses in a hidden tab while polling goes on, so 'tween from what is on screen' leaves alpha at 0 and the element glides from a stale position on return; snap on visibility change if that matters.