Skip to content

Commit 40c875d

Browse files
vincenzovitalefacebook-github-bot
authored andcommitted
Support ARG_DISABLE_HOST_LIFECYCLE_EVENTS to conditionally set mDisableHostLifecycleEvents (facebook#46509)
Summary: Pull Request resolved: facebook#46509 With ARG_DISABLE_HOST_LIFECYCLE_EVENTS it's possible to conditionally set mDisableHostLifecycleEvents when the ReactFragment gets created. ## Changelog: [Android][Fixed] ARG_DISABLE_HOST_LIFECYCLE_EVENTS in ReactFragment to allow unmounting a surface without destroying ReactHost. Reviewed By: rozele Differential Revision: D62714185 fbshipit-source-id: b6518ff67a9644421b8fe9c7cdc2aa6d62a23651
1 parent 40c5e6b commit 40c875d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ public class com/facebook/react/ReactDelegate {
184184

185185
public class com/facebook/react/ReactFragment : androidx/fragment/app/Fragment, com/facebook/react/modules/core/PermissionAwareActivity {
186186
protected static final field ARG_COMPONENT_NAME Ljava/lang/String;
187+
protected static final field ARG_DISABLE_HOST_LIFECYCLE_EVENTS Ljava/lang/String;
187188
protected static final field ARG_FABRIC_ENABLED Ljava/lang/String;
188189
protected static final field ARG_LAUNCH_OPTIONS Ljava/lang/String;
189190
protected field mReactDelegate Lcom/facebook/react/ReactDelegate;
190191
public fun <init> ()V
191-
protected fun <init> (Z)V
192192
public fun checkPermission (Ljava/lang/String;II)I
193193
public fun checkSelfPermission (Ljava/lang/String;)I
194194
protected fun getReactDelegate ()Lcom/facebook/react/ReactDelegate;

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ public class ReactFragment extends Fragment implements PermissionAwareActivity {
3030
protected static final String ARG_LAUNCH_OPTIONS = "arg_launch_options";
3131
protected static final String ARG_FABRIC_ENABLED = "arg_fabric_enabled";
3232

33+
/**
34+
* @deprecated We will remove this and use a different solution for handling Fragment lifecycle
35+
* events
36+
*/
37+
@Deprecated
38+
protected static final String ARG_DISABLE_HOST_LIFECYCLE_EVENTS =
39+
"arg_disable_host_lifecycle_events";
40+
3341
protected ReactDelegate mReactDelegate;
3442

35-
private final boolean mDisableHostLifecycleEvents;
43+
private boolean mDisableHostLifecycleEvents;
3644

3745
@Nullable private PermissionListener mPermissionListener;
3846

3947
public ReactFragment() {
4048
// Required empty public constructor
41-
this(false);
42-
}
43-
44-
/**
45-
* @param disableHostLifecycleEvents Disable forwarding lifecycle events to the {@link ReactHost}.
46-
*/
47-
protected ReactFragment(boolean disableHostLifecycleEvents) {
48-
this.mDisableHostLifecycleEvents = disableHostLifecycleEvents;
4949
}
5050

5151
/**
@@ -75,6 +75,7 @@ public void onCreate(Bundle savedInstanceState) {
7575
mainComponentName = getArguments().getString(ARG_COMPONENT_NAME);
7676
launchOptions = getArguments().getBundle(ARG_LAUNCH_OPTIONS);
7777
fabricEnabled = getArguments().getBoolean(ARG_FABRIC_ENABLED);
78+
mDisableHostLifecycleEvents = getArguments().getBoolean(ARG_DISABLE_HOST_LIFECYCLE_EVENTS);
7879
}
7980
if (mainComponentName == null) {
8081
throw new IllegalStateException("Cannot loadApp if component name is null");

0 commit comments

Comments
 (0)