Lifecycle Methods
Control widget behavior with lifecycle methods.
Overview
All DotPassport widgets share the same lifecycle methods:
Method
Description
mount()
Attach widget to DOM
update()
Update widget configuration
refresh()
Reload widget data
destroy()
Remove widget and cleanup
mount()
Attaches the widget to a DOM element.
Signature
mount(target: string | HTMLElement): voidParameters
Parameter
Type
Description
target
string | HTMLElement
CSS selector or DOM element
Examples
Error Handling
update()
Updates widget configuration without full remount.
Signature
Parameters
Parameter
Type
Description
config
Partial<WidgetConfig>
Configuration properties to update
Examples
Use Cases
Address Change (Wallet Switch)
Theme Toggle
System Theme Change
refresh()
Reloads widget data from the API.
Signature
Examples
Use Cases
After User Action
Pull-to-Refresh
destroy()
Removes the widget from DOM and cleans up resources.
Signature
Examples
Use Cases
React useEffect Cleanup
Vue onUnmounted
Page Navigation
Complete Lifecycle Example
React Hook Example
Related
Last updated
