Understanding the architectural challenge of animations in React Native
The current architecture of React Native is suboptimal when it comes to animations. Think of an animation that scales or moves a title image based on the vertical scroll value of a ScrollView
; this animation has to be calculated based on the scroll value of the ScrollView
and immediately re-render the image. The following diagram shows what would happen when using the plain React Native architecture:
Figure 6.1 – The React Native architecture while animating based on scroll values
Here, you can see the general React Native architecture. The JavaScript thread is where you write your code. Every command will be serialized and sent via the bridge to the native thread. In this thread, the command is deserialized and executed. The same happens with the user input, but it occurs the other way around.
For our animation, this means that the scroll value would have to be serialized, sent...