From 5abfb1c431366fb44d754fa174ceb46dd420a51a Mon Sep 17 00:00:00 2001 From: Johan du Toit Date: Thu, 5 Oct 2023 14:47:27 +0000 Subject: [PATCH 1/2] docs: useNavigation hook is required with static api --- versioned_docs/version-7.x/static-configuration.md | 1 + 1 file changed, 1 insertion(+) diff --git a/versioned_docs/version-7.x/static-configuration.md b/versioned_docs/version-7.x/static-configuration.md index 0d2b0858d14..ddf7b8b156d 100644 --- a/versioned_docs/version-7.x/static-configuration.md +++ b/versioned_docs/version-7.x/static-configuration.md @@ -177,5 +177,6 @@ The static API is a convenience wrapper around the dynamic API, not a full-repla - The navigation tree is static with the static API, i.e. the configuration can't be changed dynamically (e.g. updating list of screens or options based on external data). - The static configuration doesn't have access to context or props, so you can't use them in options, listeners etc. specified in the static configuration. +- The navigation object is no longer passed to your screens and you'll need to use the `useNavigation()` hook The dynamic API is still the primary API and isn't going away. So we recommend to avoid rewriting your app to use the static API if you have type-checking and deep linking setup already. Instead, consider using the static API in new projects where you know you won't need to change the configuration dynamically. From ea1afa940f66128c63060a3401525963009d6468 Mon Sep 17 00:00:00 2001 From: Johan du Toit Date: Thu, 5 Oct 2023 14:52:40 +0000 Subject: [PATCH 2/2] Add useNavigation to example --- versioned_docs/version-7.x/static-configuration.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/versioned_docs/version-7.x/static-configuration.md b/versioned_docs/version-7.x/static-configuration.md index ddf7b8b156d..ebed56d301a 100644 --- a/versioned_docs/version-7.x/static-configuration.md +++ b/versioned_docs/version-7.x/static-configuration.md @@ -19,10 +19,12 @@ The same principles apply to the static API as the dynamic API. We have navigato ```js import * as React from 'react'; import { View, Text } from 'react-native'; -import { createStaticNavigation } from '@react-navigation/native'; +import { createStaticNavigation, useNavigation } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; function HomeScreen() { + const navigation = useNavigation(); + return ( Home Screen