Skip to content

API Reference / @gtkx/navigation / Router

Type Alias: Router<State, Action> ​

Router<State, Action> = object

Defined in: node_modules/.pnpm/@react-navigation+routers@7.6.4_patch_hash=264e3b1766bd6c68d737cc5a0462f4d031997ddce4982d95ed9fbbc91906b77e/node_modules/@react-navigation/routers/lib/typescript/src/types.d.ts:113

Type Parameters ​

State ​

State extends NavigationState

Action ​

Action extends NavigationAction

Properties ​

actionCreators? ​

optional actionCreators?: ActionCreators<Action>

Defined in: node_modules/.pnpm/@react-navigation+routers@7.6.4_patch_hash=264e3b1766bd6c68d737cc5a0462f4d031997ddce4982d95ed9fbbc91906b77e/node_modules/@react-navigation/routers/lib/typescript/src/types.d.ts:174

Action creators for the router.


type ​

type: State["type"]

Defined in: node_modules/.pnpm/@react-navigation+routers@7.6.4_patch_hash=264e3b1766bd6c68d737cc5a0462f4d031997ddce4982d95ed9fbbc91906b77e/node_modules/@react-navigation/routers/lib/typescript/src/types.d.ts:118

Type of the router. Should match the type property in state. If the type doesn't match, the state will be discarded during rehydration.

Methods ​

getInitialState() ​

getInitialState(options): State

Defined in: node_modules/.pnpm/@react-navigation+routers@7.6.4_patch_hash=264e3b1766bd6c68d737cc5a0462f4d031997ddce4982d95ed9fbbc91906b77e/node_modules/@react-navigation/routers/lib/typescript/src/types.d.ts:125

Initialize the navigation state.

Parameters ​

options ​

RouterConfigOptions

Returns ​

State


getRehydratedState() ​

getRehydratedState(partialState, options): State

Defined in: node_modules/.pnpm/@react-navigation+routers@7.6.4_patch_hash=264e3b1766bd6c68d737cc5a0462f4d031997ddce4982d95ed9fbbc91906b77e/node_modules/@react-navigation/routers/lib/typescript/src/types.d.ts:133

Rehydrate the full navigation state from a given partial state.

Parameters ​

partialState ​

State | PartialState<State>

Navigation state to rehydrate from.

options ​

RouterConfigOptions

Returns ​

State


getStateForAction() ​

getStateForAction(state, action, options): State | PartialState<State> | null

Defined in: node_modules/.pnpm/@react-navigation+routers@7.6.4_patch_hash=264e3b1766bd6c68d737cc5a0462f4d031997ddce4982d95ed9fbbc91906b77e/node_modules/@react-navigation/routers/lib/typescript/src/types.d.ts:164

Take the current state and action, and return a new state. If the action cannot be handled, return null.

Parameters ​

state ​

State

State object to apply the action on.

action ​

Action

Action object to apply.

options ​

RouterConfigOptions

Returns ​

State | PartialState<State> | null


getStateForRouteFocus() ​

getStateForRouteFocus(state, key): State

Defined in: node_modules/.pnpm/@react-navigation+routers@7.6.4_patch_hash=264e3b1766bd6c68d737cc5a0462f4d031997ddce4982d95ed9fbbc91906b77e/node_modules/@react-navigation/routers/lib/typescript/src/types.d.ts:154

Take the current state and key of a route, and return a new state with the route focused

Parameters ​

state ​

State

State object to apply the action on.

key ​

string

Key of the route to focus.

Returns ​

State


getStateForRouteNamesChange() ​

getStateForRouteNamesChange(state, options): State

Defined in: node_modules/.pnpm/@react-navigation+routers@7.6.4_patch_hash=264e3b1766bd6c68d737cc5a0462f4d031997ddce4982d95ed9fbbc91906b77e/node_modules/@react-navigation/routers/lib/typescript/src/types.d.ts:141

Take the current state and updated list of route names, and return a new state.

Parameters ​

state ​

State

State object to update.

options ​

RouterConfigOptions & object

Returns ​

State


shouldActionChangeFocus() ​

shouldActionChangeFocus(action): boolean

Defined in: node_modules/.pnpm/@react-navigation+routers@7.6.4_patch_hash=264e3b1766bd6c68d737cc5a0462f4d031997ddce4982d95ed9fbbc91906b77e/node_modules/@react-navigation/routers/lib/typescript/src/types.d.ts:170

Whether the action should also change focus in parent navigator

Parameters ​

action ​

NavigationAction

Action object to check.

Returns ​

boolean