Skip to content

Commit b1a2ef5

Browse files
committed
add example linking config
1 parent 45faa70 commit b1a2ef5

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

Diff for: src/Example.bs.js

+43
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
var React = require("react");
4+
var Js_dict = require("rescript/lib/js/js_dict.js");
45
var Caml_option = require("rescript/lib/js/caml_option.js");
56
var ReactNative = require("react-native");
67
var Stack$ReactNavigation = require("./Stack.bs.js");
@@ -71,8 +72,49 @@ var $$Navigator$1 = include$1.$$Navigator;
7172

7273
var $$Screen$1 = include$1.$$Screen;
7374

75+
var linking_prefixes = ["https://www.example.com"];
76+
77+
var linking_config = {
78+
initialRouteName: "app",
79+
screens: Js_dict.fromArray([[
80+
"app",
81+
{
82+
screens: Js_dict.fromArray([
83+
[
84+
"tab1",
85+
{
86+
screens: Js_dict.fromArray([[
87+
"home",
88+
{
89+
path: ""
90+
}
91+
]])
92+
}
93+
],
94+
[
95+
"tab2",
96+
{
97+
screens: Js_dict.fromArray([[
98+
"config",
99+
{
100+
path: "/config"
101+
}
102+
]])
103+
}
104+
]
105+
])
106+
}
107+
]])
108+
};
109+
110+
var linking = {
111+
prefixes: linking_prefixes,
112+
config: linking_config
113+
};
114+
74115
function Example$RootStackScreen(props) {
75116
return React.createElement(Native.NavigationContainer, {
117+
linking: linking,
76118
children: React.createElement($$Navigator$1.make, {
77119
screenOptions: (function (param) {
78120
return {
@@ -101,6 +143,7 @@ var RootStackScreen = {
101143
$$Navigator: $$Navigator$1,
102144
$$Screen: $$Screen$1,
103145
Group: RootStackScreen_Group,
146+
linking: linking,
104147
make: Example$RootStackScreen
105148
};
106149

Diff for: src/Example.res

+32-1
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,40 @@ module MainStackScreen = {
4242
module RootStackScreen = {
4343
include Stack.Make()
4444

45+
let linking = {
46+
open Native.Linking
47+
{
48+
prefixes: ["https://www.example.com"],
49+
config: {
50+
initialRouteName: "app",
51+
screens: [
52+
(
53+
"app",
54+
{
55+
screens: [
56+
(
57+
"tab1",
58+
{
59+
screens: [("home", {path: ""})]->Js.Dict.fromArray,
60+
},
61+
),
62+
(
63+
"tab2",
64+
{
65+
screens: [("config", {path: "/config"})]->Js.Dict.fromArray,
66+
},
67+
),
68+
]->Js.Dict.fromArray,
69+
},
70+
),
71+
]->Js.Dict.fromArray,
72+
},
73+
}
74+
}
75+
4576
@react.component
4677
let make = () =>
47-
<Native.NavigationContainer>
78+
<Native.NavigationContainer linking>
4879
<Navigator screenOptions={_ => {presentation: #modal}}>
4980
<Screen name="Main" component=MainStackScreen.make />
5081
<Screen name="MyModal">

0 commit comments

Comments
 (0)