Skip to content

Commit 7dfb18f

Browse files
committed
upgrade to react-navigation 7
1 parent fd1d0e7 commit 7dfb18f

15 files changed

+2886
-5022
lines changed

package-lock.json

+2,768-4,958
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+13-11
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
"access": "public"
77
},
88
"peerDependencies": {
9-
"@react-navigation/bottom-tabs": ">=6.1.0",
10-
"@react-navigation/drawer": ">=6.1.0",
11-
"@react-navigation/material-bottom-tabs": ">=6.1.0",
12-
"@react-navigation/material-top-tabs": ">=6.1.0",
13-
"@react-navigation/native": ">=6.1.0",
14-
"@react-navigation/stack": ">=6.1.0",
15-
"@rescript/react": ">=0.11.0",
16-
"rescript-react-native": ">=0.71.0"
9+
"@react-navigation/bottom-tabs": ">=7.0.0",
10+
"@react-navigation/drawer": ">=7.0.0",
11+
"@react-navigation/material-top-tabs": ">=7.0.0",
12+
"@react-navigation/native": ">=7.0.0",
13+
"@react-navigation/stack": ">=7.0.0",
14+
"@rescript/react": ">=0.12.0",
15+
"rescript-react-native": ">=0.73.1"
16+
},
17+
"overrides": {
18+
"react": "^18.0.0"
1719
},
1820
"repository": "https://github.com/rescript-react-native/react-navigation.git",
1921
"license": "MIT",
@@ -43,13 +45,13 @@
4345
"release": "npmpub"
4446
},
4547
"devDependencies": {
46-
"@rescript/react": "^0.11.0",
48+
"@rescript/react": "^0.12.2",
4749
"husky": "^4.0.0",
4850
"lint-staged": "^10.0.0",
4951
"npmpub": "^5.0.0",
5052
"prettier": "^2.0.0",
51-
"rescript": "^11.0.0",
52-
"rescript-react-native": ">=0.71.1"
53+
"rescript": "^11.0.1",
54+
"rescript-react-native": "^0.73.1"
5355
},
5456
"prettier": {
5557
"trailingComma": "all"

bsconfig.json renamed to rescript.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"name": "rescript-react-navigation",
33
"namespace": "react-navigation",
44
"jsx": {
5-
"version": 4,
6-
"mode": "classic"
5+
"version": 4
76
},
87
"package-specs": {
98
"module": "commonjs",

src/BottomTabs.res

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type rec options = {
2929
tabBarBadge?: string,
3030
tabBarBadgeStyle?: Style.t,
3131
tabBarAccessibilityLabel?: string,
32-
tabBarTestID?: string,
32+
tabBarButtonTestID?: string,
3333
tabBarButton?: unit => React.element, // TODO: props
3434
tabBarColor?: Color.t,
3535
tabBarActiveTintColor?: string,
@@ -40,8 +40,9 @@ type rec options = {
4040
tabBarItemStyle?: Style.t,
4141
tabBarStyle?: Style.t,
4242
tabBarBackground?: unit => React.element,
43+
sceneStyle?: Style.t,
4344
\"lazy"?: bool,
44-
unmountOnBlur?: bool,
45+
popToTopOnBlur?: bool,
4546
freezeOnBlur?: bool,
4647
header?: headerParams => React.element,
4748
headerShown?: bool,
@@ -82,7 +83,6 @@ module type NavigatorModule = {
8283
~screenOptions: screenOptionsParams => options=?,
8384
~backBehavior: backBehavior=?,
8485
~detachInactiveScreens: bool=?,
85-
~sceneContainerStyle: Style.t=?,
8686
~tabBar: unit => React.element=?,
8787
~children: React.element,
8888
) => React.element

src/Core.res

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ module Navigation = {
6161
@send
6262
external navigateWithParams: (t, string, 'params) => unit = "navigate"
6363

64+
@send external navigateDeprecated: (t, string) => unit = "navigateDeprecated"
65+
@send
66+
external navigateDeprecatedWithParams: (t, string, 'params) => unit = "navigateDeprecated"
67+
6468
@send external goBack: (navigation, unit) => unit = "goBack"
6569

6670
@send

src/Drawer.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ type rec options = {
4545
drawerHideStatusBarOnOpen?: bool,
4646
drawerStatusBarAnimation?: drawerStatusBarAnimation,
4747
overlayColor?: Color.t,
48-
sceneContainerStyle?: Style.t,
48+
sceneStyle?: Style.t,
4949
gestureEnabled?: bool,
5050
gestureHandlerProps?: gestureHandlerProps,
5151
swipeEnabled?: bool,
5252
swipeEdgeWidth?: float,
5353
swipeMinDistance?: float,
5454
keyboardDismissMode?: keyboardDismissMode,
55-
unmountOnBlur?: bool,
55+
popToTopOnBlur?: bool,
5656
freezeOnBlur?: bool,
5757
headerShown?: bool,
5858
header?: headerProps => React.element,

src/Elements.res

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ module Header = {
1313
| String(string)
1414
| Function(headerTitleProps => React.element)
1515

16+
type displayMode = [#default | #generic | #minimal]
17+
1618
type headerLeftProps = {
1719
tintColor: option<Color.t>,
1820
pressColor: option<Color.t>,
1921
pressOpacity: option<float>,
20-
labelVisible: option<bool>,
22+
displayMode: option<displayMode>,
2123
}
2224

2325
type headerRightProps = {
@@ -66,7 +68,7 @@ module HeaderBackground = {
6668
module HeaderBackButton = {
6769
@react.component @module("@react-navigation/elements")
6870
external make: (
69-
~labelVisible: bool=?,
71+
~displayMode: Header.displayMode=?,
7072
~tintColor: Color.t=?,
7173
~onPress: unit => unit,
7274
) => React.element = "HeaderBackButton"

src/Example.bs.js

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict';
22

3-
var React = require("react");
43
var Js_dict = require("rescript/lib/js/js_dict.js");
54
var Caml_option = require("rescript/lib/js/caml_option.js");
65
var ReactNative = require("react-native");
6+
var JsxRuntime = require("react/jsx-runtime");
77
var Stack$ReactNavigation = require("./Stack.bs.js");
88
var Native = require("@react-navigation/native");
99

1010
function Example$HomeScreen(props) {
11-
return React.createElement(ReactNative.Text, {
11+
return JsxRuntime.jsx(ReactNative.Text, {
1212
children: "Hello Reasonable Person!"
1313
});
1414
}
@@ -18,7 +18,7 @@ var HomeScreen = {
1818
};
1919

2020
function Example$ModalScreen(props) {
21-
return React.createElement(ReactNative.Text, {
21+
return JsxRuntime.jsx(ReactNative.Text, {
2222
children: "Hello From Modal"
2323
});
2424
}
@@ -34,15 +34,15 @@ var $$Navigator = include.$$Navigator;
3434
var $$Screen = include.$$Screen;
3535

3636
function Example$MainStackScreen(props) {
37-
return React.createElement($$Navigator.make, {
38-
children: Caml_option.some(React.createElement($$Screen.make, {
37+
return JsxRuntime.jsx($$Navigator.make, {
38+
children: Caml_option.some(JsxRuntime.jsx($$Screen.make, {
3939
name: "Home",
4040
options: (function (props) {
4141
var params = props.route.params;
4242
return {
4343
title: params !== undefined ? Caml_option.valFromOption(params).name : "Reason",
4444
headerRight: (function (param) {
45-
return React.createElement(ReactNative.Button, {
45+
return JsxRuntime.jsx(ReactNative.Button, {
4646
color: "#f00",
4747
onPress: (function (param) {
4848
props.navigation.navigate("MyModal");
@@ -113,27 +113,30 @@ var linking = {
113113
};
114114

115115
function Example$RootStackScreen(props) {
116-
return React.createElement(Native.NavigationContainer, {
116+
return JsxRuntime.jsx(Native.NavigationContainer, {
117117
linking: linking,
118-
children: React.createElement($$Navigator$1.make, {
118+
children: JsxRuntime.jsxs($$Navigator$1.make, {
119119
screenOptions: (function (param) {
120120
return {
121121
presentation: "modal"
122122
};
123123
}),
124-
children: Caml_option.some(null)
125-
}, React.createElement($$Screen$1.make, {
126-
name: "Main",
127-
component: Example$MainStackScreen
128-
}), React.createElement($$Screen$1.make, {
129-
name: "MyModal",
130-
children: (function (param) {
131-
return React.createElement(Example$ModalScreen, {
132-
navigation: param.navigation,
133-
route: param.route
134-
});
124+
children: [
125+
JsxRuntime.jsx($$Screen$1.make, {
126+
name: "Main",
127+
component: Example$MainStackScreen
128+
}),
129+
JsxRuntime.jsx($$Screen$1.make, {
130+
name: "MyModal",
131+
children: (function (param) {
132+
return JsxRuntime.jsx(Example$ModalScreen, {
133+
navigation: param.navigation,
134+
route: param.route
135+
});
136+
})
135137
})
136-
}))
138+
]
139+
})
137140
});
138141
}
139142

src/MaterialBottomTabs.bs.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
22

33
var Interop = require("./Interop");
4-
var MaterialBottomTabs = require("@react-navigation/material-bottom-tabs");
4+
var ReactNavigation = require("react-native-paper/react-navigation");
55

66
var TabBarBadge = {};
77

88
function Make($star) {
9-
return Interop.adaptNavigatorModule(MaterialBottomTabs.createMaterialBottomTabNavigator());
9+
return Interop.adaptNavigatorModule(ReactNavigation.createMaterialBottomTabNavigator());
1010
}
1111

1212
var $$Navigation = {};

src/MaterialBottomTabs.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module type NavigatorModule = {
6969
type navigatorModule
7070

7171
%%private(
72-
@module("@react-navigation/material-bottom-tabs")
72+
@module("react-native-paper/react-navigation")
7373
external createMaterialBottomTabNavigator: unit => navigatorModule =
7474
"createMaterialBottomTabNavigator"
7575

src/MaterialTopTabs.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type options = {
2525
tabBarIndicator?: unit => React.element,
2626
tabBarIndicatorStyle?: Style.t,
2727
tabBarIndicatorContainerStyle?: Style.t,
28-
tabBarTestID?: string,
28+
tabBarButtonTestID?: string,
2929
tabBarActiveTintColor?: string,
3030
tabBarInactiveTintColor?: string,
3131
tabBarPressColor?: string,
@@ -57,6 +57,7 @@ type tabBarProps = {
5757
tabStyle?: Style.t,
5858
indicatorStyle?: Style.t,
5959
labelStyle?: Style.t,
60+
sceneStyle?: Style.t,
6061
style?: Style.t,
6162
renderIndicator?: React.component<{"route": route}>,
6263
activeTintColor?: string,
@@ -86,7 +87,6 @@ module type NavigatorModule = {
8687
~tabBarPosition: tabBarPosition=?,
8788
~keyboardDismissMode: keyboardDismissMode=?,
8889
~initialLayout: layout=?,
89-
~sceneContainerStyle: Style.t=?,
9090
~style: Style.t=?,
9191
~tabBar: tabBarProps => React.element=?,
9292
~children: React.element,

src/Native.bs.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
var Linking = {};
55

6+
var NavigationIndependentTree = {};
7+
68
var NavigationContainer = {};
79

810
var ServerContainer = {};
@@ -12,6 +14,7 @@ var CommonActions = {};
1214
var Link = {};
1315

1416
exports.Linking = Linking;
17+
exports.NavigationIndependentTree = NavigationIndependentTree;
1518
exports.NavigationContainer = NavigationContainer;
1619
exports.ServerContainer = ServerContainer;
1720
exports.CommonActions = CommonActions;

src/Native.res

+32-13
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@ type themeColors = {
77
notification: string,
88
}
99

10+
type themeFonts = {
11+
regular: ReactNative.Style.t,
12+
medium: ReactNative.Style.t,
13+
bold: ReactNative.Style.t,
14+
heavy: ReactNative.Style.t,
15+
}
16+
1017
type theme = {
1118
dark: bool,
1219
colors: themeColors,
20+
fonts: themeFonts,
1321
}
1422

1523
@module("@react-navigation/native")
@@ -35,6 +43,11 @@ module Linking = {
3543
}
3644
}
3745

46+
module NavigationIndependentTree = {
47+
@module("@react-navigation/native") @react.component
48+
external make: unit => React.element = "NavigationIndependentTree"
49+
}
50+
3851
module NavigationContainer = {
3952
type state = Js.Json.t
4053
type navigationState = state => unit
@@ -48,7 +61,7 @@ module NavigationContainer = {
4861
~theme: theme=?,
4962
~linking: Linking.t=?,
5063
~children: React.element,
51-
~independent: bool=?,
64+
~navigationInChildEnabled: bool=?,
5265
) => React.element = "NavigationContainer"
5366

5467
@send
@@ -115,9 +128,11 @@ module CommonActions = {
115128
@module("@react-navigation/native")
116129
external useLinkTo: string => unit = "useLinkTo"
117130

118-
type linkPropsIn = {
119-
to_: string,
120-
action: unit => unit,
131+
type linkPropsIn<'params> = {
132+
screen?: string,
133+
params?: 'params,
134+
action?: Core.action,
135+
href?: string,
121136
}
122137
type linkPropsOut = {
123138
href: string,
@@ -126,20 +141,24 @@ type linkPropsOut = {
126141
}
127142

128143
@module("@react-navigation/native")
129-
external useLinkProps: linkPropsIn => linkPropsOut = "useLinkProps"
144+
external useLinkProps: linkPropsIn<'params> => linkPropsOut = "useLinkProps"
130145

131-
type linkBuilderOut<'a> = (string, 'a) => string
146+
type linkBuilderOut<'params> = {
147+
buildHref: (string, 'params) => string,
148+
buildAction: string => Core.action,
149+
}
132150

133151
@module("@react-navigation/native")
134-
external useLinkBuilder: unit => linkBuilderOut<'a> = "useLinkBuilder"
152+
external useLinkBuilder: unit => linkBuilderOut<'params> = "useLinkBuilder"
135153

136154
module Link = {
137-
@module("@react-navigation/native") @react.component
138-
external make: (
139-
~to_: string=?,
140-
~action: unit => unit=?,
141-
~children: React.element,
142-
) => React.element = "Link"
155+
type props<'params> = {
156+
...linkPropsIn<'params>,
157+
children: React.element,
158+
}
159+
160+
@module("@react-navigation/native")
161+
external make: props<'params> => React.element = "Link"
143162
}
144163

145164
@module("@react-navigation/native")

0 commit comments

Comments
 (0)