|
1 |
| -## Objective-C |
| 1 | +## Java |
2 | 2 |
|
3 | 3 | React Native Brownfield provides first-class support for Java.
|
4 | 4 |
|
@@ -72,12 +72,12 @@ A function used to initialize a React Native Brownfield singleton. Keep in mind
|
72 | 72 |
|
73 | 73 | Params:
|
74 | 74 |
|
75 |
| -| Param | Required | Type | Description | |
76 |
| -| ----------------------- | -------- | -------------------- | ------------------------------------------------------- | |
77 |
| -| application | Yes | Application | Main application. | |
78 |
| -| rnHost | No* | ReactNativeHost | A instance of [ReactNativeHost](https://bit.ly/2ZnwgnA). | |
79 |
| -| packages | No* | List<ReactPackage> | List of your React Native Native modules. | |
80 |
| -| options | No* | HashMap<String, Any> | Map of initial options. __Options listed below.__ | |
| 75 | +| Param | Required | Type | Description | |
| 76 | +| ----------------------- | -------- | -------------------- | --------------------------------------------------------- | |
| 77 | +| application | Yes | Application | Main application. | |
| 78 | +| rnHost | No* | ReactNativeHost | An instance of [ReactNativeHost](https://bit.ly/2ZnwgnA). | |
| 79 | +| packages | No* | List<ReactPackage> | List of your React Native Native modules. | |
| 80 | +| options | No* | HashMap<String, Any> | Map of initial options. __Options listed below.__ | |
81 | 81 |
|
82 | 82 | > * - Those fields aren't itself required, but at least one of them is. See examples below.
|
83 | 83 |
|
@@ -144,12 +144,9 @@ Examples:
|
144 | 144 |
|
145 | 145 | **Properties:**
|
146 | 146 |
|
147 |
| -| Property | Type | Default | Description | |
148 |
| -| -------------------- | --------- | -------------- | -------------------------------------------------- | |
149 |
| -| bridge | RCTBridge | nil | Launch options, typically passed from AppDelegate. | |
150 |
| -| entryFile | NSString | index | Path to JavaScript root. | |
151 |
| -| fallbackResource | NSString | nil | Path to bundle fallback resource. | |
152 |
| -| bundlePath | NSString | main.jsbundle | Path to bundle fallback resource. | |
| 147 | +| Property | Type | Default | Description | |
| 148 | +| --------------- | --------------- | -------------- | --------------------------------------------------------- | |
| 149 | +| reactNativeHost | ReactNativeHost | null | An instance of [ReactNativeHost](https://bit.ly/2ZnwgnA). | |
153 | 150 |
|
154 | 151 | ---
|
155 | 152 |
|
@@ -179,6 +176,111 @@ Examples:
|
179 | 176 |
|
180 | 177 | ---
|
181 | 178 |
|
| 179 | +#### ReactNativeActivity |
| 180 | + |
| 181 | +An activity rendering `ReactRootView` with a given module name. It automatically uses an instance of a bridge created in `startReactNative` method. It works well with exposed JavaScript module. All the lifecycles are proxied to `ReactInstanceManager`. |
| 182 | + |
| 183 | +```java |
| 184 | + import com.callstack.reactnativebrownfield.ReactNativeActivity; |
| 185 | +``` |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +**Statics:** |
| 190 | + |
| 191 | +`createReactActivityIntent` |
| 192 | + |
| 193 | +Creates an Intent with ReactNativeActivity, you can use it as a parameter in the `startActivity` method in order to push a new activity with embedded React Native. |
| 194 | + |
| 195 | +Params: |
| 196 | + |
| 197 | +| Param | Required | Type | Description | |
| 198 | +| ----------------------- | -------- | ------------------------------------------- | ----------------------------------------------------------- | |
| 199 | +| context | Yes | Context | Application context. | |
| 200 | +| moduleName | Yes | String | Name of React Native component registered to `AppRegistry`. | |
| 201 | +| initialProps | No | Bundle || HashMap<String, *> || ReadableMap | Initial properties to be passed to React Native component. | |
| 202 | + |
| 203 | +Examples: |
| 204 | + |
| 205 | +```java |
| 206 | + ReactNativeActivity.createReactActivityIntent(context, "ReactNative"); |
| 207 | +``` |
| 208 | + |
| 209 | +```java |
| 210 | + Bundle bundle = new Bundle(); |
| 211 | + bundle.putInt("score", 12); |
| 212 | + |
| 213 | + ReactNativeActivity.createReactActivityIntent(context, "ReactNative", bundle); |
| 214 | +``` |
| 215 | + |
| 216 | +```java |
| 217 | + HashMap map = new HashMap<String, *>(); |
| 218 | + map.put("score", 12); |
| 219 | + |
| 220 | + ReactNativeActivity.createReactActivityIntent(context, "ReactNative", map); |
| 221 | +``` |
| 222 | + |
| 223 | +```java |
| 224 | + WritableMap map = new WritableMap(); |
| 225 | + map.putInt("score", 12); |
| 226 | + |
| 227 | + ReactNativeActivity.createReactActivityIntent(context, "ReactNative", map); |
| 228 | +``` |
| 229 | + |
| 230 | +--- |
| 231 | + |
| 232 | +#### ReactNativeFragment |
| 233 | + |
| 234 | +An fragment rendering `ReactRootView` with a given module name. It automatically uses an instance of a bridge 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. |
| 235 | + |
| 236 | +```java |
| 237 | + import com.callstack.reactnativebrownfield.ReactNativeActivity; |
| 238 | +``` |
| 239 | + |
| 240 | +--- |
| 241 | + |
| 242 | +**Statics:** |
| 243 | + |
| 244 | +`createReactNativeFragment` |
| 245 | + |
| 246 | +Creates a Fragment with ReactNativeActivity, you can use it as a parameter in the `startActivity` method in order to push a new activity with embedded React Native. |
| 247 | + |
| 248 | +Params: |
| 249 | + |
| 250 | +| Param | Required | Type | Description | |
| 251 | +| ----------------------- | -------- | ------------------------------------------- | ----------------------------------------------------------- | |
| 252 | +| moduleName | Yes | String | Name of React Native component registered to `AppRegistry`. | |
| 253 | +| initialProps | No | Bundle || HashMap<String, *> || ReadableMap | Initial properties to be passed to React Native component. | |
| 254 | + |
| 255 | +Examples: |
| 256 | + |
| 257 | +```java |
| 258 | + ReactNativeActivity.createReactNativeFragment("ReactNative"); |
| 259 | +``` |
| 260 | + |
| 261 | +```java |
| 262 | + Bundle bundle = new Bundle(); |
| 263 | + bundle.putInt("score", 12); |
| 264 | + |
| 265 | + ReactNativeActivity.createReactNativeFragment("ReactNative", bundle); |
| 266 | +``` |
| 267 | + |
| 268 | +```java |
| 269 | + HashMap map = new HashMap<String, *>(); |
| 270 | + map.put("score", 12); |
| 271 | + |
| 272 | + ReactNativeActivity.createReactNativeFragment("ReactNative", map); |
| 273 | +``` |
| 274 | + |
| 275 | +```java |
| 276 | + WritableMap map = new WritableMap(); |
| 277 | + map.putInt("score", 12); |
| 278 | + |
| 279 | + ReactNativeActivity.createReactActivityIntent(context, "ReactNative", map); |
| 280 | +``` |
| 281 | + |
| 282 | +--- |
| 283 | + |
182 | 284 | ### Linking
|
183 | 285 |
|
184 | 286 | You can find an example app [here](../example/java).
|
|
0 commit comments