ServerContainer component provides utilities to render your app on server with the correct navigation state.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ServerContainer component should wrap your entire app during server rendering. Note that you still need a
NavigationContainer in your app,
ServerContainer doesn't replace it.'
server rendering guide for a detailed guide and examples.
If you attach a
ref to the container, you can get the options for the current screen after rendering the app. The
ref will contain a method called
getCurrentOptions which will return an object with options for the focused screen in the navigation tree:
Then you can access the options for the screen from this object and put it in the HTML:
Note that the
options object can be undefined if you are not rendering a navigator on the initial render.
Location object containing the location to use for server rendered output. You can pass the
search properties matching the
location object in the browsers:
1 2 3
Normally, you'd construct this object based on the incoming request.
Basic example with Koa (don't use as is in production):
1 2 3 4 5 6 7 8 9