Skip to content

Commit e7b98a8

Browse files
committed
docs: added docs for Jetpack Compose via AndroidFragment
1 parent 4e3729b commit e7b98a8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/KOTLIN.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,20 @@ ReactNativeFragment.createReactNativeFragment("ReactNative", map)
231231

232232
### Usage in Jetpack Compose
233233

234-
You can easily wrap the `ReactNativeFragment` inside a `AndroidFragment` composable to integrate React Native into your Jetpack Compose application:
234+
You can easily wrap the `ReactNativeFragment` inside a `AndroidFragment` composable to integrate React Native into your Jetpack Compose application. Since the AndroidFragment itself acts as a factory for the given Fragment class, you can pass the required arguments using a Bundle.
235+
236+
The `arguments` passed to the `AndroidFragment` match the ones that can be passed to the `ReactNativeFragment.createReactNativeFragment` factory, yet need to be packed inside a Bundle, as follows:
237+
- ***(required)*** the JS component name, a `String` under the `ReactNativeFragmentArgNames.ARG_MODULE_NAME` (equivalent to `"arg_module_name"`) constant
238+
- *(optional)* the initial properties, a `Bundle` under the `ReactNativeFragmentArgNames.ARG_LAUNCH_OPTIONS` (equivalent to `"arg_launch_options"`) constant
235239

236240
```kotlin
237241
import androidx.fragment.compose.AndroidFragment
238242

239243
import com.callstack.reactnativebrownfield.constants.ReactNativeFragmentArgNames
240244

241245
AndroidFragment<ReactNativeFragment>(arguments = Bundle().apply {
242-
putString(ReactNativeFragmentArgNames.ARG_MODULE_NAME, "RnAndroidRockApp")
246+
putString(ReactNativeFragmentArgNames.ARG_MODULE_NAME, "ReactNative")
247+
putBundle(ReactNativeFragmentArgNames.ARG_LAUNCH_OPTIONS, initialProps)
243248
}, modifier = Modifier.fillMaxSize())
244249
```
245250

0 commit comments

Comments
 (0)