Skip to content

Commit 51f889f

Browse files
committed
docs: updated documentation
1 parent cd41911 commit 51f889f

File tree

3 files changed

+80
-68
lines changed

3 files changed

+80
-68
lines changed

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ npm install @callstack/react-native-brownfield
5151

5252
First, we need to package our React Native app as an XCFramework or Fat-AAR.
5353

54-
#### With RNEF
54+
#### With Rock
5555

56-
Follow [Integrating with Native Apps](https://www.rnef.dev/docs/brownfield/intro) steps in RNEF docs and run:
56+
Follow [Integrating with Native Apps](https://www.rockjs.dev/docs/brownfield/intro) steps in Rock docs and run:
5757

58-
- `rnef package:ios` for iOS
59-
- `rnef package:aar` for Android
58+
- `rock package:ios` for iOS
59+
- `rock package:aar` for Android
6060

6161
#### With custom scripts
6262

63-
Instead of using RNEF, you can create your own custom packaging scripts. Here are base versions for iOS and Android that you'll need to adjust for your project-specific setup:
63+
Instead of using Rock, you can create your own custom packaging scripts. Here are base versions for iOS and Android that you'll need to adjust for your project-specific setup:
6464

6565
- [Example iOS script](https://github.com/callstackincubator/modern-brownfield-ref/blob/main/scripts/build-xcframework.sh)
6666
- [Example Android script](https://github.com/callstackincubator/modern-brownfield-ref/blob/main/scripts/build-aar.sh)
@@ -121,17 +121,13 @@ import android.view.LayoutInflater
121121
import android.view.View
122122
import android.view.ViewGroup
123123
import androidx.fragment.app.Fragment
124-
import com.callstack.rnbrownfield.RNViewFactory // exposed by RN app framework
125124

126125
class RNAppFragment : Fragment() {
127126
override fun onCreateView(
128127
inflater: LayoutInflater,
129128
container: ViewGroup?,
130129
savedInstanceState: Bundle?,
131-
): View? =
132-
this.context?.let {
133-
RNViewFactory.createFrameLayout(it)
134-
}
130+
): View? = ReactNativeBrownfield.shared.createView(activity, "BrownFieldTest")
135131
}
136132
```
137133

@@ -166,7 +162,9 @@ class MainActivity : AppCompatActivity() {
166162

167163
override fun onCreate(savedInstanceState: Bundle?) {
168164
super.onCreate(savedInstanceState)
169-
ReactNativeHostManager.shared.initialize(this.application)
165+
ReactNativeHostManager.shared.initialize(this.application) {
166+
println("JS bundle loaded")
167+
}
170168

171169
showRNAppBtn = findViewById(R.id.show_rn_app_btn)
172170
showRNAppBtn.setOnClickListener {
@@ -228,7 +226,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
228226
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
229227
<!-- prettier-ignore -->
230228
| [<img src="https://avatars0.githubusercontent.com/u/7837457?s=460&v=4" width="100px;" alt="Michał Chudziak"/><br /><sub><b>Michał Chudziak</b></sub>](https://twitter.com/michalchudziak)<br />[💻](https://github.com/callstack/react-native-brownfield/commits?author=michalchudziak "Code") [📖](https://github.com/callstack/react-native-brownfield/commits?author=michalchudziak "Documentation") [🤔](#ideas-michalchudziak "Ideas, Planning, & Feedback") | [<img src="https://avatars1.githubusercontent.com/u/16336501?s=400&v=4" width="100px;" alt="Piotr Drapich"/><br /><sub><b>Piotr Drapich</b></sub>](https://twitter.com/dratwas)<br />[💻](https://github.com/callstack/react-native-brownfield/commits?author=dratwas "Code") [🤔](#ideas-dratwas "Ideas, Planning, & Feedback") |
231-
| :---: | :---: |
229+
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
232230

233231
<!-- ALL-CONTRIBUTORS-LIST:END -->
234232

docs/JAVA.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ With react-native >= 0.80.0, an auto-generated file was added which is responsib
2525
you will have this file `ReactNativeApplicationEntryPoint` available. If you're consuming this library in a RN android library which is backed by
2626
`com.callstack.react:brownfield-gradle-plugin`, then this file will also be available.
2727

28-
Below is the code you need to add before you call `RNBrownfield.initialize`:
28+
Below is the code you need to add before you call `ReactNativeBrownfield.initialize`:
2929

3030
```java
3131
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
3232

3333
loadReactNative(application);
34-
RNBrownfield.initialize(application, packages);
34+
ReactNativeBrownfield.initialize(application, packages);
3535
```
3636

3737
<hr/>
@@ -62,15 +62,15 @@ A function used to initialize a React Native Brownfield singleton. Keep in mind
6262

6363
Params:
6464

65-
| Param | Required | Type | Description |
66-
| ----------------------- | -------- | -------------------- | --------------------------------------------------------- |
67-
| application | Yes | `Application` | Main application. |
68-
| rnHost | No* | `ReactNativeHost` | An instance of [ReactNativeHost](https://bit.ly/2ZnwgnA). |
69-
| packages | No* | `List<ReactPackage>` | List of your React Native Native modules. |
70-
| options | No* | `HashMap<String, Any>` | Map of initial options. __Options listed below.__ |
71-
| onJSBundleLoaded | No* | `OnJSBundleLoaded` | Callback invoked after JS bundle is fully loaded. |
65+
| Param | Required | Type | Description |
66+
| ---------------- | ------------ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
67+
| application | Yes | `Application` | Main application. |
68+
| reactHost | Exclusively* | `ReactHost` | An instance of [ReactHost](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactHost.kt). |
69+
| packages | Exclusively* | `List<ReactPackage>` | List of your React Native Native modules. |
70+
| options | Exclusively* | `HashMap<String, Any>` | Map of initial options. __Options listed below.__ |
71+
| onJSBundleLoaded | Exclusively* | `OnJSBundleLoaded` | Callback invoked after JS bundle is fully loaded. |
7272

73-
> * - Those fields aren't itself required, but at least one of them is. See examples below.
73+
> * - From the marked fields, exactly one must be specified, excluding the others. See examples below.
7474
7575
Available options:
7676
- `useDevSupport`: `Boolean` - Flag to use dev support.
@@ -103,7 +103,7 @@ private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
103103

104104
ReactNativeBrownfield.initialize(this, mReactNativeHost);
105105

106-
OR
106+
// OR
107107

108108
ReactNativeBrownfield.initialize(this, mReactNativeHost, initialized -> {
109109
// JS bundle loaded
@@ -115,7 +115,7 @@ List<ReactPackage> packages = new PackageList(this).getPackages();
115115

116116
ReactNativeBrownfield.initialize(this, packages);
117117

118-
OR
118+
// OR
119119

120120
ReactNativeBrownfield.initialize(this, packages, initialized -> {
121121
// JS bundle loaded
@@ -130,7 +130,7 @@ options.put("mainModuleName", "example/index");
130130

131131
ReactNativeBrownfield.initialize(this, options);
132132

133-
OR
133+
// OR
134134

135135
ReactNativeBrownfield.initialize(this, options, initialized -> {
136136
// JS bundle loaded
@@ -153,26 +153,26 @@ ReactNativeBrownfield.getShared()
153153

154154
**Properties:**
155155

156-
| Property | Type | Default | Description |
157-
| --------------- | --------------- | -------------- | --------------------------------------------------------- |
158-
| reactNativeHost | `ReactNativeHost` | null | An instance of [ReactNativeHost](https://bit.ly/2ZnwgnA). |
156+
| Property | Type | Default | Description |
157+
| --------- | ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
158+
| reactHost | `ReactHost` | null | An instance of [ReactHost](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactHost.kt). |
159159

160160
---
161161

162162
**Methods:**
163163

164164
`createView`
165165

166-
Creates a React Native view with a given module name. It automatically uses an instance of React Native created in `startReactNative` method. This is useful when embedding React Native views directly in your native layouts.
166+
Creates a React Native view with a given module name. It automatically uses an instance of React Native created in `initialize` method. This is useful when embedding React Native views directly in your native layouts.
167167

168168
Params:
169169

170-
| Param | Required | Type | Description |
171-
| -------------- | -------- | ------------------- | ----------------------------------------------------------- |
172-
| context | Yes | `Context` | Android context to create the view |
173-
| activity | No | `FragmentActivity` | Activity hosting the view, used for lifecycle management |
174-
| moduleName | Yes | `String` | Name of React Native component registered to `AppRegistry` |
175-
| launchOptions | No | `Bundle` | Initial properties to be passed to React Native component |
170+
| Param | Required | Type | Description |
171+
| ------------- | -------- | ------------------ | ---------------------------------------------------------- |
172+
| context | Yes | `Context` | Android context to create the view |
173+
| activity | No | `FragmentActivity` | Activity hosting the view, used for lifecycle management |
174+
| moduleName | Yes | `String` | Name of React Native component registered to `AppRegistry` |
175+
| launchOptions | No | `Bundle` | Initial properties to be passed to React Native component |
176176

177177
Returns:
178178
`FrameLayout` - A view containing the React Native component.
@@ -193,7 +193,7 @@ container.addView(reactView);
193193

194194
#### `ReactNativeFragment`
195195

196-
An fragment rendering `ReactRootView` with a given module name. It automatically uses an instance of a React Native created in `startReactNative` method. It works well with exposed JavaScript module. All the lifecycles are proxied to `ReactInstanceManager`. It's the simplest way to embed React Native into your navigation stack.
196+
An fragment rendering `ReactRootView` with a given module name. It automatically uses an instance of a React Native created in `initialize` method. It works well with exposed JavaScript module. All the lifecycles are proxied to `ReactInstanceManager`. It's the simplest way to embed React Native into your navigation stack.
197197

198198
```java
199199
import com.callstack.reactnativebrownfield.ReactNativeFragment;
@@ -209,10 +209,10 @@ Creates a Fragment with `ReactNativeActivity`, you can use it as a parameter in
209209

210210
Params:
211211

212-
| Param | Required | Type | Description |
213-
| ----------------------- | -------- | ------------------------------------------- | ----------------------------------------------------------- |
214-
| moduleName | Yes | `String` | Name of React Native component registered to `AppRegistry`. |
215-
| initialProps | No | `Bundle` \|\| `HashMap<String, *>` \|\| `ReadableMap` | Initial properties to be passed to React Native component. |
212+
| Param | Required | Type | Description |
213+
| ------------ | -------- | ----------------------------------------------------- | ----------------------------------------------------------- |
214+
| moduleName | Yes | `String` | Name of React Native component registered to `AppRegistry`. |
215+
| initialProps | No | `Bundle` \|\| `HashMap<String, *>` \|\| `ReadableMap` | Initial properties to be passed to React Native component. |
216216

217217
Examples:
218218

0 commit comments

Comments
 (0)