From ddf0079ec5b7570c104c2be9530b1b39cbeef164 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 7 Nov 2023 09:41:23 -0800 Subject: [PATCH] Fix rendering of RN Tester New Architecture examples in Android 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 --- .../com/facebook/react/uiapp/component/MyLegacyViewManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt index 1ff6b782db7..d7e101b7d3c 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyLegacyViewManager.kt @@ -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) {