Skip to content

Commit

Permalink
Fix rendering of RN Tester New Architecture examples in Android
Browse files Browse the repository at this point in the history
Summary:
When bridgeless is enabled, RN Tester New Architecture examples crashed with a StackOverflow Exception
The root cause of this issue is that MyLegacyViewManager is sending an event to JS during the execution of MyLegacyViewManager.createViewInstance() method.

This is a problem because the delivery of events depend on the "id" of the view, but the "id" of the view is set after MyLegacyViewManager.createViewInstance() finishes executing.

The documentations "implicitly" mentions to not set props during the execution of the ViewManager.createViewInstance() method:

https://reactnative.dev/docs/native-components-android#2-implement-method-createviewinstance

To fix this issue I'm removing the execution of the method that triggers the event.

bypass-github-export-checks

changelog: [Android][Fix] Fix rendering of 'RN Tester New Architecture examples' when bridgeless is enabled

Reviewed By: fkgozali

Differential Revision: D51047007

fbshipit-source-id: 17be493f79114fa402029063e79fabc1d90efc17
  • Loading branch information
mdvacca authored and facebook-github-bot committed Nov 7, 2023
1 parent b561d46 commit 45dce98
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class MyLegacyViewManager(reactContext: ReactApplicationContext) :
override fun getName(): String = REACT_CLASS

override fun createViewInstance(themedReactContext: ThemedReactContext): MyNativeView =
MyNativeView(themedReactContext).apply { setBackgroundColor(Color.RED) }
MyNativeView(themedReactContext)

@ReactProp(name = ViewProps.OPACITY, defaultFloat = 1f)
override fun setOpacity(view: MyNativeView, opacity: Float) {
Expand Down

0 comments on commit 45dce98

Please sign in to comment.