55
66## Status
77
8- WIP WIP WIP WIP
8+ Work in progress. These bindings are used successfully in several apps, but are
9+ not complete yet and still subject to change.
910
1011## Example
1112
12- Instantiate a navigation module with your ` screenProps ` type (Navigation.re):
13-
14- ``` reason
15- include ReactNavigation.Make({
16- type screenProps = {
17- .
18- "someProp": int,
19- };
20- });
21- ```
22-
2313A screen component with dynamic navigation options (Screen1.re):
2414
2515``` reason
2616open ReactNative;
27- open Navigation ;
17+ open ReactNavigation ;
2818
2919[@react.component]
3020let make = (~navigation, ~screenProps) => {
31- <Text> {React.string("Hello world!")} </Text>,
21+ <Text> {React.string("Hello world!")} </Text>;
3222};
3323
34- make->setDynamicNavigationOptions(params => {
24+ make->NavigationOptions. setDynamicNavigationOptions(params => {
3525 let navigation = params##navigation;
3626 let navigationOptions = params##navigationOptions;
3727 let screenProps = params##screenProps;
@@ -44,7 +34,7 @@ make->setDynamicNavigationOptions(params => {
4434A stack navigator containing this screen (MyStackNavigator.re):
4535
4636``` reason
47- open Navigation ;
37+ open ReactNavigation ;
4838
4939let routes = {
5040 "Screen1": Screen1.make,
@@ -53,20 +43,45 @@ let routes = {
5343};
5444
5545let navigator = StackNavigator.make(routes);
56- navigator->setNavigationOptions(NavigationOptions.t(~gesturesEnabled=false, ()));
46+
47+ navigator->NavigationOptions.setNavigationOptions(
48+ NavigationOptions.t(~gesturesEnabled=false, ()),
49+ );
5750```
5851
5952The main React component of the app (App.re):
6053
6154``` reason
62- open Navigation;
55+ open ReactNavigation;
56+
57+ module MyAppContainer =
58+ AppContainerFunctor.Make({
59+ type screenProps = {. "someProp": int};
60+ let navigator = MyStackNavigator.navigator;
61+ });
62+
63+ [@react.component]
64+ let make = () => {
65+ let screenProps = {"someProp": 42};
66+
67+ <MyAppContainer screenProps />;
68+ };
69+ ```
70+
71+ Alternatively (without a functor, but using ` React.createElement ` ):
72+
73+ ``` reason
74+ open ReactNavigation;
6375
64- module AppContainer = (val makeAppContainer(MyStackNavigator.navigator) );
76+ let appContainer = AppContainer. makeAppContainer(MyStackNavigator.navigator);
6577
6678[@react.component]
6779let make = () => {
6880 let screenProps = {"someProp": 42};
6981
70- <AppContainer screenProps />;
82+ React.createElement(
83+ appContainer,
84+ AppContainer.makeProps(~screenProps, ()),
85+ );
7186};
7287```
0 commit comments