rive-react icon indicating copy to clipboard operation
rive-react copied to clipboard

useRive hook: rive instance is null inside onLoad callback.

Open mattp0123 opened this issue 7 months ago • 0 comments

Why?

import { useRive } from '@rive-app/react-canvas'

function MyComponent() {
  const { rive } = useRive({
    onLoad: () => {
      console.log(rive) // null
    },
    // ...
  })
  return (
    // ...
  )
}

Is below the correct way to use rive instance?

import { useRive } from '@rive-app/react-canvas'

function MyComponent() {
  const { rive } = useRive({
    // ...
  })
  useEffect(() => {
    if (rive) {
      console.log(rive)
    }
  }, [rive])
  return (
    // ...
  )
}

mattp0123 avatar Jul 23 '25 02:07 mattp0123