You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: versioned_docs/version-7.x/server-rendering.md
+52-6
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,9 @@ title: Server rendering
4
4
sidebar_label: Server rendering
5
5
---
6
6
7
+
import Tabs from '@theme/Tabs';
8
+
import TabItem from '@theme/TabItem';
9
+
7
10
This guide will cover how to server render your React Native app using React Native for Web and React Navigation. We'll cover the following cases:
8
11
9
12
1. Rendering the correct layout depending on the request URL
@@ -130,16 +133,59 @@ app.use(async (ctx) => {
130
133
});
131
134
```
132
135
133
-
Make sure that you have specified a `title` option in your screens:
136
+
Make sure that you have specified a `title` option for your screens:
137
+
138
+
<Tabs groupId="config" queryString="config">
139
+
<TabItem value="static" label="Static" default>
140
+
141
+
```js
142
+
constStack=createNativeStackNavigator({
143
+
screens: {
144
+
Home: {
145
+
screen: HomeScreen,
146
+
options: {
147
+
// highlight-next-line
148
+
title:'My App',
149
+
},
150
+
},
151
+
Profile: {
152
+
screen: ProfileScreen,
153
+
options: ({ route }) => ({
154
+
// highlight-next-line
155
+
title:`${route.params.name}'s Profile`,
156
+
}),
157
+
},
158
+
},
159
+
});
160
+
```
161
+
162
+
</TabItem>
163
+
<TabItem value="dynamic" label="Dynamic">
134
164
135
165
```js
136
-
<Stack.Screen
137
-
name="Profile"
138
-
component={ProfileScreen}
139
-
options={{ title:'My profile' }}
140
-
/>
166
+
<Stack.Navigator>
167
+
<Stack.Screen
168
+
name="Home"
169
+
component={HomeScreen}
170
+
options={{
171
+
// highlight-next-line
172
+
title:'My App',
173
+
}}
174
+
/>
175
+
<Stack.Screen
176
+
name="Profile"
177
+
component={ProfileScreen}
178
+
options={({ route }) => ({
179
+
// highlight-next-line
180
+
title:`${route.params.name}'s Profile`,
181
+
})}
182
+
/>
183
+
</Stack.Navigator>
141
184
```
142
185
186
+
</TabItem>
187
+
</Tabs>
188
+
143
189
## Handling 404 or other status codes
144
190
145
191
When [rendering a screen for an invalid URL](configuring-links.md#handling-unmatched-routes-or-404), we should also return a `404` status code from the server.
0 commit comments