React Routeways - API Reference • Docs
React Routeways - API Reference / Navigation
Interface: Navigation
Properties
goTo()
goTo: <
T
>(route
, …params
) => () =>void
Creates a stable callback that navigates to the specified route by pushing a state to the history, the same way as navigate would. Ideal to use on event props of React elements.
This function is the equivalent of wrapping the navigate function
on a React.useCallback(..)
hook.
Example
function MyComp(): ReactElement {
cosnt { goTo } = useNavigation();
return (
<Button
variant="secondary"
onClick={goTo(MainRoutes.users.edit, { userId: 523 })}
>
Edit User
</Button>
)
}
Type Parameters
• T extends Routeway
Parameters
• route: T
the route to navigate to
• …params: Parameters
<T
["makeUrl"
]>
the path vars and/or query params of the route (if any)
Returns
Function
Returns
void
Defined in
src/lib/hooks/useNavigation.hook.ts:34
navigate()
navigate: <
T
>(route
, …params
) =>void
Navigates to the specified route by pushing a state to the history. The first argument is a Routeways route, allowing its types definitions to let you know if path variables are required (with type checks). You can also pass query parameters when registered to the route. Both path vars and query params can be added in the second argument.
Example
function MyComp(): ReactElement {
cosnt { navigate } = useNavigation();
const handleClick = (): void => {
navigate(MainRoutes.users.edit, { userId: 523 });
};
return ...
}
Type Parameters
• T extends Routeway
Parameters
• route: T
the route to navigate to
• …params: Parameters
<T
["makeUrl"
]>
the path vars and/or query params of the route (if any)
Returns
void
Defined in
src/lib/hooks/useNavigation.hook.ts:58
reset()
reset: <
T
>(route
, …params
) =>void
Navigates to the specified route by resetting the current history. The first argument is a Routeways route, allowing its types definitions to let you know if path variables are required (with type checks). You can also pass query parameters when registered to the route. Both path vars and query params can be added in the second argument.
Example
function MyComp(): ReactElement {
cosnt { reset } = useNavigation();
const handleClick = (): void => {
navigate(MainRoutes.home, { dashboard: true });
};
return ...
}
Type Parameters
• T extends Routeway
Parameters
• route: T
the route to navigate to
• …params: Parameters
<T
["makeUrl"
]>
the path vars and/or query params of the route (if any)
Returns
void
Defined in
src/lib/hooks/useNavigation.hook.ts:82
resetTo()
resetTo: <
T
>(route
, …params
) => () =>void
Creates a stable callback that navigates to the specified route by resetting the current history, the same way as reset would. Ideal to use on event props of React elements.
This function is the equivalent of wrapping the reset function on
a React.useCallback(..)
hook.
Example
function MyComp(): ReactElement {
cosnt { resetTo } = useNavigation();
return (
<Button
variant="primary"
onClick={resetTo(MainRoutes.home, { dashboard: true })}
>
Restart
</Button>
)
}
Type Parameters
• T extends Routeway
Parameters
• route: T
the route to navigate to
• …params: Parameters
<T
["makeUrl"
]>
the path vars and/or query params of the route (if any)
Returns
Function
Returns
void