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
- The hook returns the [navigation state](navigation-state.md) in the `state` property. This is the current state of the navigator. There's also a `descriptors` object which contains the data and helpers for each screen in the navigator.
59
59
- We get the focused route from the state with `state.routes[state.index]` - as `state.index` is the index of the currently focused route in the `state.routes` array.
60
60
- Then we get the corresponding descriptor for the focused route with `descriptors[focusedRoute.key]` and call the `render()` method on it to get the React element for the screen.
61
-
-The content of the navigator is wrapped in `NavigationContent` to provide appropriate context and wrappers.
61
+
-We use the `render` function returned by `useNavigationBuilder` to render the content of the navigator with appropriate context and wrappers.
62
62
63
63
With this, we have a basic stack navigator that renders only the focused screen. Unlike the built-in stack navigator, this doesn't keep unfocused screens rendered. But you can loop through `state.routes` and render all of the screens if you want to keep them mounted. You can also read `descriptor.options` to get the [options](screen-options.md) to handle the screen's title, header, and other options.
64
64
@@ -90,6 +90,7 @@ The hook returns an object with following properties:
90
90
-`navigation` - The navigation object for the screen. You don't need to pass this to the screen manually. But it's useful if we're rendering components outside the screen that need to receive `navigation` prop as well, such as a header component.
91
91
-`options` - A getter which returns the options such as `title` for the screen if they are specified.
92
92
-`render` - A function which can be used to render the actual screen. Calling `descriptors[route.key].render()` will return a React element containing the screen content. It's important to use this method to render a screen, otherwise any child navigators won't be connected to the navigation tree properly.
93
+
-`render` - A function to render the navigator's content with context and wrappers necessary for the navigator to work.
- The hook returns the [navigation state](navigation-state.md) in the `state` property. This is the current state of the navigator. There's also a `descriptors` object which contains the data and helpers for each screen in the navigator.
59
59
- We get the focused route from the state with `state.routes[state.index]` - as `state.index` is the index of the currently focused route in the `state.routes` array.
60
60
- Then we get the corresponding descriptor for the focused route with `descriptors[focusedRoute.key]` and call the `render()` method on it to get the React element for the screen.
61
-
-The content of the navigator is wrapped in `NavigationContent` to provide appropriate context and wrappers.
61
+
-We use the `render` function returned by `useNavigationBuilder` to render the content of the navigator with appropriate context and wrappers.
62
62
63
63
With this, we have a basic stack navigator that renders only the focused screen. Unlike the built-in stack navigator, this doesn't keep unfocused screens rendered. But you can loop through `state.routes` and render all of the screens if you want to keep them mounted. You can also read `descriptor.options` to get the [options](screen-options.md) to handle the screen's title, header, and other options.
64
64
@@ -90,6 +90,7 @@ The hook returns an object with following properties:
90
90
-`navigation` - The navigation object for the screen. You don't need to pass this to the screen manually. But it's useful if we're rendering components outside the screen that need to receive `navigation` prop as well, such as a header component.
91
91
-`options` - A getter which returns the options such as `title` for the screen if they are specified.
92
92
-`render` - A function which can be used to render the actual screen. Calling `descriptors[route.key].render()` will return a React element containing the screen content. It's important to use this method to render a screen, otherwise any child navigators won't be connected to the navigation tree properly.
93
+
-`render` - A function to render the navigator's content with context and wrappers necessary for the navigator to work.
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/upgrading-from-7.x.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -219,6 +219,29 @@ See [Custom navigators](custom-navigators.md) for more details.
219
219
220
220
### Changes to navigators
221
221
222
+
#### Custom navigators need to use the `render` callback
223
+
224
+
Previously, `useNavigationBuilder` returned a `NavigationContent` component for wrapping the navigator's content. The API was problematic, as `NavigationContent` needed to be stable despite using dynamic data. The approach we used to achieve this was not compatible with concurrent rendering.
225
+
226
+
To solve this properly, we replaced it with a `render` callback that takes the navigator's content as an argument and returns a React element:
See [Custom navigators](custom-navigators.md) for more details.
244
+
222
245
#### Native Bottom Tabs are now default
223
246
224
247
Previously, the Bottom Tab Navigator used a JavaScript-based implementation and a native implementation was available under `@react-navigation/bottom-tabs/unstable`. The `@react-navigation/bottom-tabs/unstable` entry point has been removed and it has been merged into the main package.
0 commit comments