Skip to content

Commit 66ec947

Browse files
committed
Update SSR docs for static rendering
1 parent 17c6783 commit 66ec947

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

versioned_docs/version-7.x/server-rendering.md

+52-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: Server rendering
44
sidebar_label: Server rendering
55
---
66

7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
710
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:
811

912
1. Rendering the correct layout depending on the request URL
@@ -130,16 +133,59 @@ app.use(async (ctx) => {
130133
});
131134
```
132135
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+
const Stack = 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">
134164
135165
```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>
141184
```
142185
186+
</TabItem>
187+
</Tabs>
188+
143189
## Handling 404 or other status codes
144190
145191
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

Comments
 (0)