react-spring

  • onRest 애니메이션이 물리적으로 정지했을 때 → UI 상태 업데이트용1
  • onResolve Promise가 resolve될 때 → 비동기 플로우 제어용
const [springs, api] = useSpring(() => ({
  x: 0,
  onRest: () => setStatus('stopped'), // UI 상태
  onResolve: () => console.log('done'), // Promise 기반 로직
}))

// Promise 방식도 가능
await api.start({ x: 100 })

Footnotes

  1. Events - react-spring: onRest — “Called when the animation comes to a stand-still.” / onResolve — “Called when the promise for the update is resolved.” ↩

`#523`