Currently there is one singleton React Native view manager corresponding to an annotated Composable and this setup is required by React Native. But currently the flows that propagate React Native props to the Composable are defined on this view manager, which does not make sense if you have multiple instances of the view rendered in React Native. Instead the helper structures need to be maintained per instance of the view.
On Android, we fix this by adding a ComposeViewWrapper that holds the compose view and the helper structures and is initialized in createViewInstance instead of a ComposeView directly.
On iOS this is more complicated as the RN view manager is in Obj-C, the view wrapper is in Kotlin and the view instance is created in Obj-C. To have the view wrapper per view we add a factory that creates this class. So the view wrapper and the view can be created together.
Currently there is one singleton React Native view manager corresponding to an annotated Composable and this setup is required by React Native. But currently the flows that propagate React Native props to the Composable are defined on this view manager, which does not make sense if you have multiple instances of the view rendered in React Native. Instead the helper structures need to be maintained per instance of the view.
On Android, we fix this by adding a
ComposeViewWrapper
that holds the compose view and the helper structures and is initialized increateViewInstance
instead of aComposeView
directly.On iOS this is more complicated as the RN view manager is in Obj-C, the view wrapper is in Kotlin and the view instance is created in Obj-C. To have the view wrapper per view we add a factory that creates this class. So the view wrapper and the view can be created together.