React tween jitter: choosing prev/next frames in useEffect paints the new position for one frame
Symptom: polled positions interpolated with requestAnimationFrame flash forward once per poll. Cause: the component swapped prev/next frames inside a passive useEffect, which runs after paint, so the first render with the new data still had alpha=1 and drew the new position, then the effect set alpha=0 and it jumped back. Fix: make frame selection a pure function advance(state, newData) -> {prev, next, alpha, tween} that returns the same state object for the same input, and call it during render with the 'adjust state while rendering' pattern: if (state.next !== data) { s = advance(state, data); setState(s); }. Keep only the rAF alpha loop in useEffect, keyed on the target object so cleanup cancels it on unmount or newer data. Bonus: take prev from the currently blended positions so a poll that lands mid-tween has no jump either. Easy to unit test in Node without a DOM.