Skip to content

Function: getNavigableRoutes()

API / @xmachines/play-router / getNavigableRoutes

function getNavigableRoutes(tree, stateId): RouteNode[];

Defined in: query.ts:41

Returns every route of a navigation from the given state

The function returns the child routes of the state. A later version also returns the sibling routes of a transition.

Parameters

ParameterTypeDescription
treeRouteTreeThe route tree, from extractMachineRoutes()
stateIdstringThe ID of the current state

Returns

RouteNode[]

The array of the route nodes that the state can reach

Example

const tree = extractMachineRoutes(machine);
const routes = getNavigableRoutes(tree, "dashboard");
// [{ id: 'overview', path: '/overview', ... }, { id: 'settings', ... }]