Just pass a boolean called `open`. Here's the React component:
import { useRive, useStateMachineInput } from '@rive-app/react-canvas';
import { useEffect } from 'react';
const STATE_MACHINE = 'State Machine 1';
interface Props {
open: boolean;
}
export default function HamburgerIcon({ open }: Props) {
const { rive, RiveComponent } = useRive({
src: '/rive/hamburger_menu.riv',
stateMachines: STATE_MACHINE,
autoplay: true,
});
const openAnimation = useStateMachineInput(rive, STATE_MACHINE, 'open');
useEffect(() => {
if (!openAnimation) return;
// @ts-ignore
openAnimation.value = open;
}, [open, openAnimation]);
return ;
}
License
Viewing