Skip to content

Commit

Permalink
Update SSR docs for static rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jun 24, 2024
1 parent 17c6783 commit 66ec947
Showing 1 changed file with 52 additions and 6 deletions.
58 changes: 52 additions & 6 deletions versioned_docs/version-7.x/server-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ title: Server rendering
sidebar_label: Server rendering
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

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:

1. Rendering the correct layout depending on the request URL
Expand Down Expand Up @@ -130,16 +133,59 @@ app.use(async (ctx) => {
});
```
Make sure that you have specified a `title` option in your screens:
Make sure that you have specified a `title` option for your screens:
<Tabs groupId="config" queryString="config">
<TabItem value="static" label="Static" default>
```js
const Stack = createNativeStackNavigator({
screens: {
Home: {
screen: HomeScreen,
options: {
// highlight-next-line
title: 'My App',
},
},
Profile: {
screen: ProfileScreen,
options: ({ route }) => ({
// highlight-next-line
title: `${route.params.name}'s Profile`,
}),
},
},
});
```
</TabItem>
<TabItem value="dynamic" label="Dynamic">
```js
<Stack.Screen
name="Profile"
component={ProfileScreen}
options={{ title: 'My profile' }}
/>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{
// highlight-next-line
title: 'My App',
}}
/>
<Stack.Screen
name="Profile"
component={ProfileScreen}
options={({ route }) => ({
// highlight-next-line
title: `${route.params.name}'s Profile`,
})}
/>
</Stack.Navigator>
```
</TabItem>
</Tabs>
## Handling 404 or other status codes
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.
Expand Down

0 comments on commit 66ec947

Please sign in to comment.