Skip to content

API Reference / @gtkx/navigation / useRootNavigationState

Function: useRootNavigationState() ​

useRootNavigationState<ParamList, T>(navigationRef, selector): T | undefined

Defined in: packages/navigation/src/use-root-navigation-state.ts:16

Selects a value from the root navigation state of the NavigationContainer that navigationRef is passed to. Use it in components outside the navigators, such as window actions, where useNavigationState throws. The component re-renders when the container becomes ready, after every navigation, and when the container is removed or replaced.

Type Parameters ​

ParamList ​

ParamList extends ParamListBase

T ​

T

Parameters ​

NavigationContainerRefWithCurrent<ParamList>

The ref from createNavigationContainerRef or useNavigationContainerRef that the container receives as ref.

selector ​

(state) => T

Derives the value from the root state.

Returns ​

T | undefined

The selected value, or undefined while no ready container holds the ref.