Data binding in React Native not working as expected
Hello,
Yesterday my colleague and I spent many hours debugging my Rive scene. We could not understand why from our typescript file (we’re building a ReactNative app) it was impossible to change the data bound to the artboard. The data was binding correctly in this file. We had no problem changing such data binding in other files, but in this one we could not.
I thought that perhaps my file/view model was corrupted, because I reproduced my view model in other files, and it worked fine. But if I copied the artboard, along with its view model/animations, it was not working anymore. So I tested the file in Unity, and here, it worked perfectly as expected, no issues at all.
We managed to find the root of the issue after a long investigation:
My file had one state machine, with a few animations set up in it. However, they were all one-shot, and they had all run once already. We had the idea to make one of these animations loop: suddenly, the data binding in our ReactNative app worked perfectly. Additionally we read this in the documentation:
At runtime in a state machine, if no looping animations or active blend states are playing, the runtime will preemptively “pause” itself until a state machine input or Rive Listener triggers the next transition in the state machine.
Our theory is that in ReactNative, if all animations finished playing, then the Rive scene can’t refresh, even if we send it new data.
Interestingly though, when I made some files with no animations at all in the state machine, the data binding worked fine. (They did require a state machine for the data binding to work though.)
I’m reporting this because this was quite an obscure behaviour to debug and I would like to know if this is intended/known, or if it’s actually a bug. I’m still learning Rive and React Native so clarity on the behaviour of data binding with React Native would be very helpful; and perhaps a clearer note in the documentation for other lost souls (or perhaps we missed something?).
Happy to share files/videos if that would help.
Thank you!