Skip to content

Commit c7d62a1

Browse files
javachemeta-codesync[bot]
authored andcommitted
Deprecate fabricEnabled from ReactFragment (#57764)
Summary: Pull Request resolved: #57764 Fabric is now unconditionally enabled for this fragment path, so the per-fragment override is dead. Remove the argument and builder API. Changelog: [Android][Changed] - Deprecate fabricEnabled on ReactFragment Reviewed By: mdvacca Differential Revision: D114045331 fbshipit-source-id: 9d61e088e742196bf5b06dfa15b49a1dda79c7c1
1 parent f535c97 commit c7d62a1

1 file changed

Lines changed: 10 additions & 26 deletions

File tree

  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react

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

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import android.view.LayoutInflater
1515
import android.view.View
1616
import android.view.ViewGroup
1717
import androidx.fragment.app.Fragment
18-
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags
1918
import com.facebook.react.modules.core.PermissionAwareActivity
2019
import com.facebook.react.modules.core.PermissionListener
2120

@@ -30,31 +29,18 @@ public open class ReactFragment : Fragment(), PermissionAwareActivity {
3029

3130
public override fun onCreate(savedInstanceState: Bundle?) {
3231
super.onCreate(savedInstanceState)
32+
3333
var mainComponentName: String? = null
3434
var launchOptions: Bundle? = null
35-
var fabricEnabled = false
3635
arguments?.let { args ->
3736
mainComponentName = args.getString(ARG_COMPONENT_NAME)
3837
launchOptions = args.getBundle(ARG_LAUNCH_OPTIONS)
39-
fabricEnabled = args.getBoolean(ARG_FABRIC_ENABLED)
4038
@Suppress("DEPRECATION")
4139
disableHostLifecycleEvents = args.getBoolean(ARG_DISABLE_HOST_LIFECYCLE_EVENTS)
4240
}
4341
checkNotNull(mainComponentName) { "Cannot loadApp if component name is null" }
4442

45-
reactDelegate =
46-
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture()) {
47-
ReactDelegate(requireActivity(), reactHost, mainComponentName, launchOptions)
48-
} else {
49-
@Suppress("DEPRECATION")
50-
ReactDelegate(
51-
requireActivity(),
52-
reactNativeHost,
53-
mainComponentName,
54-
launchOptions,
55-
fabricEnabled,
56-
)
57-
}
43+
reactDelegate = ReactDelegate(requireActivity(), reactHost, mainComponentName, launchOptions)
5844
}
5945

6046
/**
@@ -176,7 +162,8 @@ public open class ReactFragment : Fragment(), PermissionAwareActivity {
176162
public class Builder {
177163
public var componentName: String? = null
178164
public var launchOptions: Bundle? = null
179-
public var fabricEnabled: Boolean = false
165+
166+
@Deprecated("Fabric is always enabled") public var fabricEnabled: Boolean = true
180167

181168
/**
182169
* Set the Component name for our React Native instance.
@@ -200,20 +187,19 @@ public open class ReactFragment : Fragment(), PermissionAwareActivity {
200187
return this
201188
}
202189

203-
public fun build(): ReactFragment = newInstance(componentName, launchOptions, fabricEnabled)
204-
205-
@Deprecated(
206-
"You should not change call ReactFragment.setFabricEnabled. Instead enable the NewArchitecture for the whole application with newArchEnabled=true in your gradle.properties file"
207-
)
190+
@Deprecated("Fabric can no longer be disabled")
208191
public fun setFabricEnabled(fabricEnabled: Boolean): Builder {
209-
this.fabricEnabled = fabricEnabled
210192
return this
211193
}
194+
195+
public fun build(): ReactFragment = newInstance(componentName, launchOptions)
212196
}
213197

214198
public companion object {
215199
protected const val ARG_COMPONENT_NAME: String = "arg_component_name"
216200
protected const val ARG_LAUNCH_OPTIONS: String = "arg_launch_options"
201+
202+
@Deprecated("Fabric is always enabled")
217203
protected const val ARG_FABRIC_ENABLED: String = "arg_fabric_enabled"
218204

219205
@Deprecated(
@@ -225,19 +211,17 @@ public open class ReactFragment : Fragment(), PermissionAwareActivity {
225211
/**
226212
* @param componentName The name of the react native component
227213
* @param launchOptions The launch options for the react native component
228-
* @param fabricEnabled Flag to enable Fabric for ReactFragment
229214
* @return A new instance of fragment ReactFragment.
230215
*/
231216
private fun newInstance(
232217
componentName: String?,
233218
launchOptions: Bundle?,
234-
fabricEnabled: Boolean,
235219
): ReactFragment {
236220
val args =
237221
Bundle().apply {
238222
putString(ARG_COMPONENT_NAME, componentName)
239223
putBundle(ARG_LAUNCH_OPTIONS, launchOptions)
240-
putBoolean(ARG_FABRIC_ENABLED, fabricEnabled)
224+
@Suppress("DEPRECATION") putBoolean(ARG_FABRIC_ENABLED, true)
241225
}
242226
return ReactFragment().apply { setArguments(args) }
243227
}

0 commit comments

Comments
 (0)