How to data bind colors from React Native to Rive animation?
Hi Rive,
I’m trying to data bind colors in a Rive animation used in a React Native app.
In the Rive app, I have a Palette ViewModel with four colors:
Ribbon color 200
Ribbon color 400
Ribbon color 500
Ribbon color 700
I want these to control the fill colors in my Rive file (a ribbon animation), so the color changes dynamically based on the data.
What’s the best way to hook this up in React Native?
We try to use the useRiveColor hook but have problems mapping to the given color.
const [setRiveRef, riveRef] = useRive();
const [color, setColor] = useRiveColor(riveRef, 'Palette/Ribbon color 200');
useEffect(() => {
if (riveRef) {
setColor('#ff01f7ff');
}
}, [riveRef, setColor]);
return (
<Rive
ref={setRiveRef}
autoplay={false}
resourceName="animation_bow_and_ribbon"
/>)