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

Lines changed: 2768 additions & 4958 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 11 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 23 additions & 20 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)