Hooks
useWalletNavigation
Hook for managing navigation state and history within the wallet widget
Import
Usage
Return Type: useWalletNavigation
The hook returns an object with navigation controls and state:
Properties
setNavigation
(navigation: Navigation) => void
Function to navigate to a new view. Automatically manages history:
- If navigating to ‘home’, clears history
- Otherwise, adds new location to history stack
- Automatically scrolls to the top of the view
history
History
Current navigation history stack containing the sequence of visited views.
setHistory
(history: History) => void
Direct history manipulation function. It’s recommended to use setNavigation
instead when possible because setNavigation
:
- Automatically scrolls to the top of the view
- Handles special cases like clearing history when navigating to ‘home’
- Ensures consistent history stack management
- Provides a more maintainable and predictable navigation flow
goBack
() => void
Function to navigate back to the previous view in history.
Navigation Object
When using setNavigation
, you provide a Navigation
object with:
Property | Type | Description |
---|---|---|
location | string | The view/route to navigate to |
params | Record<string, any> | Optional parameters to pass to the view |
Features
- Automatic History Management: Maintains a stack of visited views
- Home Navigation: Clears history when navigating to ‘home’
- Automatic Scrolling: Scrolls to top of view on navigation
- Back Navigation: Supports going back to previous views
- Parameter Support: Pass data between views via navigation params
Examples
Basic Navigation
Navigation with Parameters
Using Back Navigation
Accessing History
Was this page helpful?