Function: extractRoute()
Documentation / @xmachines/play-router / extractRoute
function extractRoute(node, path, stateMap): RouteInfo | null;Defined in: extract-route.ts:26
Extract route information from state node with validation
States with meta.route are “routable” - they can receive play.route events (when machine is wrapped with formatPlayRouteTransitions).
Parameters
| Parameter | Type | Description |
|---|---|---|
node | StateNode | XState StateNode to extract route from |
path | string[] | State path segments from root |
stateMap | Map<string, StateNode<MachineContext, EventObject>> | Map of all state IDs to StateNodes for validation |
Returns
RouteInfo | null
RouteInfo if state has meta.route, null otherwise
Throws
If route path is malformed (missing leading /)
Throws
If route references non-existent state
Example
const node = { id: "dashboard", meta: { route: "/dashboard" },};