Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4224d8d

Browse files
authored
Combine AppContainerFunctor and AppContainer again, get example to run. (#7)
1 parent 99e753d commit 4224d8d

File tree

9 files changed

+80
-70
lines changed

9 files changed

+80
-70
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ The main React component of the app (App.re):
9494
open ReactNavigation;
9595
9696
module MyAppContainer =
97-
AppContainerFunctor.Make({
97+
AppContainer.Make({
9898
type screenProps = {. "someProp": int};
9999
let navigator = MyStackNavigator.navigator;
100100
});

‎bsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"bsc-flags": ["-bs-no-version-header"],
2020
"warnings": {
21-
"number": "+102"
21+
"number": "+102-105"
2222
},
2323
"bs-dependencies": ["reason-react", "reason-react-native"]
2424
}

‎example/bsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
"bs-dependencies": [
1919
"reason-react",
2020
"reason-react-native",
21-
"reason-react-navigation"
21+
"@reason-react-native/navigation"
2222
]
2323
}

‎example/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"dependencies": {
1717
"@unimodules/react-native-adapter": "^2.0.1",
18-
"bs-platform": "^5.0.4",
18+
"bs-platform": "^5.2.0",
1919
"expo": "^33.0.7",
2020
"react": "16.8.6",
2121
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
@@ -27,4 +27,4 @@
2727
"babel-preset-expo": "^5.0.0",
2828
"expo-yarn-workspaces": "^1.2.0"
2929
}
30-
}
30+
}

‎example/yarn.lock‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,10 +1349,10 @@ browserslist@^4.6.0, browserslist@^4.6.2:
13491349
electron-to-chromium "^1.3.164"
13501350
node-releases "^1.1.23"
13511351

1352-
bs-platform@^5.0.4:
1353-
version "5.0.4"
1354-
resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-5.0.4.tgz#d406ef43c12d1b19d8546884d8b5b4e0fb709372"
1355-
integrity sha512-rXM+ztN8wYXQ4ojfFGylvPOf8GRLOvM94QJsMMV9VpsLChKCjesWMNybTZvpoyNsESu2nC5q+C9soG+BPhuUFQ==
1352+
bs-platform@^5.2.0:
1353+
version "5.2.0"
1354+
resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-5.2.0.tgz#0ec317273daed573491c105f68ea48826a285b7a"
1355+
integrity sha512-miyePsOF9VbuhT5QD5E/hb+l454Fo4MAcg5xV1GJhbWxmejuF/X7mCYUsNrK1UUAaYt8hnoyFdeLG22sxVta9A==
13561356

13571357
bser@^2.0.0:
13581358
version "2.1.0"

‎src/AppContainer.bs.js‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
1+
'use strict';
2+
3+
var ReactNavigation = require("react-navigation");
4+
5+
function Make(S) {
6+
var make = ReactNavigation.createAppContainer(S.navigator);
7+
return {
8+
make: make
9+
};
10+
}
11+
12+
exports.Make = Make;
13+
/* react-navigation Not a pure module */

‎src/AppContainer.re‎

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
// Low-level, zero-cost bindings to AppContainer.
1+
// There are two ways to use the AppContainer module.
22
//
3-
// Usage:
3+
// 1. With React.createElement, zero-cost
4+
// ======================================
45
//
5-
// let appContainer = AppContainer.makeAppContainer(rootNavigator);
6+
// open ReactNavigation;
67
//
7-
// React.createElement(
8-
// appContainer,
9-
// AppContainer.makeProps(
10-
// ~screenProps, /* ... more props ... */
11-
// (),
12-
// ),
13-
// );
8+
// let appContainer = AppContainer.makeAppContainer(MyStackNavigator.navigator);
9+
//
10+
// [@react.component]
11+
// let make = () => {
12+
// let screenProps = {"someProp": 42};
13+
//
14+
// React.createElement(
15+
// appContainer,
16+
// AppContainer.makeProps(~screenProps, ()),
17+
// );
18+
// };
1419

1520
type persistNavigationState = NavigationState.t => Js.Promise.t(unit);
1621
type loadNavigationState = unit => Js.Promise.t(option(NavigationState.t));
@@ -40,3 +45,46 @@ external makeProps:
4045
external makeAppContainer:
4146
Navigator.t => React.component(appContainerProps('screenProps)) =
4247
"createAppContainer";
48+
49+
// 2. Without create element, using a functor instead
50+
// ==================================================
51+
//
52+
// open ReactNavigation;
53+
//
54+
// module MyAppContainer =
55+
// AppContainer.Make({
56+
// type screenProps = {. "someProp": int};
57+
// let navigator = MyStackNavigator.navigator;
58+
// });
59+
//
60+
// [@react.component]
61+
// let make = () => {
62+
// let screenProps = {"someProp": 42};
63+
//
64+
// <MyAppContainer screenProps />;
65+
// };
66+
67+
module Make = (S: {
68+
type screenProps;
69+
let navigator: Navigator.t;
70+
}) => {
71+
[@bs.module "react-navigation"]
72+
external make:
73+
Navigator.t => React.component(appContainerProps(S.screenProps)) =
74+
"createAppContainer";
75+
76+
[@bs.obj]
77+
external makeProps:
78+
(
79+
~persistNavigationState: persistNavigationState=?,
80+
~loadNavigationState: loadNavigationState=?,
81+
~screenProps: S.screenProps=?,
82+
~setNavigatorRef: Js.Nullable.t(NavigationContainer.t) => unit=?,
83+
~key: string=?,
84+
unit
85+
) =>
86+
appContainerProps(S.screenProps) =
87+
"";
88+
89+
let make = make(S.navigator);
90+
};

‎src/AppContainerFunctor.bs.js‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎src/AppContainerFunctor.re‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /