Skip to main content
V
2d ago

React Native - Methods not working

I've been trying to get rive methods working with a web asset

My code is basically below, however nothing happens when I press my button. I can see the asset rendering but not moving

import Rive, { RiveRef } from 'rive-react-native';


function App() {
  const riveRef = React.useRef<RiveRef>(null);

  const handlePlay = () => { riveRef.current?.play() };

  return (
    <>
      <Rive ref={riveRef} url="https://public.rive.app/community/runtime-files/2195-4346-avatar-pack-use-case.riv" autoplay={false} artboardName="Avatar 1"
            stateMachineName="avatar" />
      <Button onPress={handlePlay} title="Play">
    </>
  );
}

1 reply
8h ago

The code looks right, but the URL looks like it's pointing directly to a community file. I don't think that will load properly, even if you have autoplay: true . I would recommend using a .riv bundled into your app or one that's hosted on a CDN.

If you're building for iOS, be sure the .riv is in Build Phases > Copy Bundle Resources