Skip to content

Commit adbdc2f

Browse files
daweeMoOx
authored andcommitted
react-native-template-reason: Update using reason-react-native (#481)
* use monorepo post script + rewrite App.re * post review fixes * fix platform matching * fix template wording
1 parent ca997bb commit adbdc2f

5 files changed

Lines changed: 44 additions & 125 deletions

File tree

‎react-native-template-reason/README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ experience.
77

88
## Setup
99

10+
### Command line
11+
12+
Install bs-platform with the following command:
13+
14+
```sh
15+
yarn add -D bs-platform
16+
```
17+
1018
### IDE
1119

1220
To get the best development experience possible, we recommend you to use

‎react-native-template-reason/bsconfig.json‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "my-reason-react-native-app",
33
"refmt": 3,
44
"reason": {
5-
"react-jsx": 2
5+
"react-jsx": 3
66
},
77
"package-specs": {
88
"module": "es6",
@@ -15,5 +15,8 @@
1515
"subdirs": true
1616
}
1717
],
18-
"bs-dependencies": ["bs-react-native", "reason-react"]
19-
}
18+
"bs-dependencies": [
19+
"reason-react",
20+
"reason-react-native"
21+
]
22+
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"bs-platform": "^5.0.1",
32
"reason-react": "^0.7.0",
4-
"bs-react-native": "^0.11.0"
5-
}
3+
"reason-react-native": "../reason-react-native"
4+
}

‎react-native-template-reason/src/App.bs.js‎

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

‎react-native-template-reason/src/App.re‎

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,50 @@
44
*
55
* Converted from https://github.com/facebook/react-native/blob/d752446b23e0a12171ca0c01d20f5be625f40455/template/App.js
66
*/
7-
open BsReactNative;
7+
open ReactNative;
88

99
let instructions =
10-
switch (Platform.os()) {
11-
| IOS(_) => "Press Cmd+R to reload,\n" ++ "Cmd+D or shake for dev menu"
12-
| Android =>
10+
switch (Platform.os) {
11+
| os when os == Platform.ios =>
12+
"Press Cmd+R to reload,\n" ++ "Cmd+D or shake for dev menu"
13+
| os when os == Platform.android =>
1314
"Double tap R on your keyboard to reload,\n"
1415
++ "Shake or press menu button for dev menu"
15-
| exception (Platform.UnknownPlatform(p)) when p == "web" => "Press Cmd+R to reload."
16-
| exception (Platform.UnknownPlatform(_p)) => ""
16+
| os when os == Platform.web => "Press Cmd+R to reload."
17+
| _ => ""
1718
};
1819

1920
let styles =
2021
Style.(
2122
StyleSheet.create({
2223
"container":
23-
style([
24-
flex(1.),
25-
justifyContent(Center),
26-
alignItems(Center),
27-
backgroundColor(String("#F5FCFF")),
28-
]),
24+
style(
25+
~flex=1.,
26+
~justifyContent=`center,
27+
~alignItems=`center,
28+
~backgroundColor="#F5FCFF",
29+
(),
30+
),
2931
"welcome":
30-
style([
31-
fontSize(Float(20.)),
32-
textAlign(Center),
33-
margin(Pt(10.)),
34-
]),
32+
style(~fontSize=20., ~textAlign=`center, ~margin=pt(10.), ()),
3533
"instructions":
36-
style([
37-
textAlign(Center),
38-
color(String("#333333")),
39-
marginBottom(Pt(5.)),
40-
]),
34+
style(
35+
~textAlign=`center,
36+
~color="#333333",
37+
~marginBottom=pt(5.),
38+
(),
39+
),
4140
})
4241
);
4342

43+
[@react.component]
4444
let app = () =>
45-
<View
46-
style={
47-
styles##container;
48-
}>
49-
<Text style={styles##welcome}>
50-
"Welcome to (Bs) React Native!"->ReasonReact.string
45+
<View style=styles##container>
46+
<Text style=styles##welcome>
47+
"Welcome to (Reason) React Native!"->React.string
5148
</Text>
52-
<Text style={styles##instructions}>
53-
"To get started, edit src/App.re"->ReasonReact.string
54-
</Text>
55-
<Text style={styles##instructions}>
56-
instructions->ReasonReact.string
49+
<Text style=styles##instructions>
50+
"To get started, edit src/App.re"->React.string
5751
</Text>
52+
<Text style=styles##instructions> instructions->React.string </Text>
5853
</View>;

0 commit comments

Comments
 (0)