rive-app / rive-react

React runtime for Rive
https://rive-app.github.io/rive-react
MIT License
755 stars 27 forks source link

rive animation first time load failed #233

Open ninibear030 opened 4 months ago

ninibear030 commented 4 months ago

Hi guys, i am using next 13 with "@rive-app/react-canvas": "^4.8.1" and this is my code

  const { RiveComponent, rive } = useRive({
    src: "xxxx.riv",
    stateMachines: STATE_MACHINE_NAME,
    artboard: "xxxx",
    autoplay: true,
    layout: new Layout({ fit: Fit.Contain }),
  }); 

sometimes the animation cant autoplay properly, (it looks broken like how it look in rive app before start the animation) its like 25% chance this will happened and i cant find a way to detect it.

i tried below it also doesnt work

autoplay: false
useEffect(()=>{ if(rive) rive.play()},[])
or
useEffect(()=>{ if(rive) rive.play()},[rive])
ninibear030 commented 4 months ago

plss help ;-;