Skip to content

Commit 2da7047

Browse files
java docs
1 parent 0d7ebde commit 2da7047

File tree

3 files changed

+117
-15
lines changed

3 files changed

+117
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img alt="React Native Brownfield" src="https://user-images.githubusercontent.com/7837457/63517391-33651080-c4ef-11e9-88ca-a14374400ed4.png" width="800">
2+
<img alt="React Native Brownfield" src="https://user-images.githubusercontent.com/7837457/63594721-7f7b8800-c5b7-11e9-87ef-a0898cd22fcc.png" width="800">
33
</p>
44

55
<p align="center">

docs/JAVA.md

Lines changed: 115 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Objective-C
1+
## Java
22

33
React Native Brownfield provides first-class support for Java.
44

@@ -72,12 +72,12 @@ A function used to initialize a React Native Brownfield singleton. Keep in mind
7272

7373
Params:
7474

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.__ |
8181

8282
> * - Those fields aren't itself required, but at least one of them is. See examples below.
8383
@@ -144,12 +144,9 @@ Examples:
144144

145145
**Properties:**
146146

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). |
153150

154151
---
155152

@@ -179,6 +176,111 @@ Examples:
179176

180177
---
181178

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+
182284
### Linking
183285

184286
You can find an example app [here](../example/java).

docs/OBJECTIVE_C.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Examples:
112112

113113
#### ReactNativeViewController
114114

115-
A view controller that's rendering `RCTRootView` within its bounds. It automatically uses an instance of a bridge created in `startReactNative` method. It works well with exposed JavaScript method. It's the simplest way to embed React Native into your navigation stack.
115+
A view controller that's rendering `RCTRootView` within its bounds. It automatically uses an instance of a bridge created in `startReactNative` method. It works well with exposed JavaScript module. It's the simplest way to embed React Native into your navigation stack.
116116

117117
You can import it from:
118118

0 commit comments

Comments
 (0)