rive-app / rive-react

React runtime for Rive

Home Page:https://rive-app.github.io/rive-react

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rive artboard not updating when state changes.

mihael998 opened this issue · comments

I have a React component where I use a Rive animation with useRive hook.
In the beggining i set the artboard parameter conditionally based on an external prop like so:

const { RiveComponent, rive } = useRive({ src: "/animations/hamburger_menu.riv", stateMachines: "stateMachine", autoplay: true, artboard: theme === NavbarComponentTheme.Orange ? "White" : "Grey", });

The problem is that when the prop changes the artboard doesn't change.

How should I manage this problem?

Hi @mihael998 , we currently aren't listening to these parameter changes, but we definitely should. There's a bit of work under the hood to coordinate this. We'll work on adding support for this. In the mean time, you might try two different components for this bit. We'll update on this issue when we get support for this!