Function: findRouteById()
API / @xmachines/play-router / findRouteById
function findRouteById(tree, id): RouteNode | undefined;Defined in: find-route.ts:59
Finds a route node by its state ID
The function looks the route node up by the ID property of the state. It gives you
the URL path of a state ID, for the update of the browser URL after a play.route
transition.
Parameters
| Parameter | Type | Description |
|---|---|---|
tree | RouteTree | The route tree, from extractMachineRoutes |
id | string | The state ID, for example ‘dashboard’ or ‘settings.profile’ |
Returns
RouteNode | undefined
The route node, or undefined when the function finds none
Example
const tree = extractMachineRoutes(machine);const node = findRouteById(tree, "dashboard");if (node) { console.log(node.fullPath); // '/dashboard'}