Skip to content

[Feature]: Recommended way to reload app after chain / wallet switches ? #2289

@pellyadolfo

Description

@pellyadolfo

Is your request related to a problem?

Not really. Missing a discussion board for best practices so I am opening here to get guidance on where to post usage questions.

Feature Description

What is the recommended way to reload the app after chain / wallet switches / disconnect ?

Alternative Solutions

  • catching window.ethereum events

window.ethereum.on('accountsChanged', (accounts: any) => { console.log('accountsChanged. Reloading') window.location.reload(); }); window.ethereum.on('chainChanged', (chainId: any) => { console.log('chainChanged. Reloading') window.location.reload(); }); window.ethereum.on('disconnect', (accounts: any) => { console.log('disconnect. Reloading') window.location.reload(); });

  • subscride to wallet updates adding a flag to prevent infinite loop of first rendering (React)

    const wallets2 = web3Onboard.state.select('wallets')
    wallets.subscribe(wallet => { ... ))

Anything else?

A discussions board would help adopters. Github has a discussions tab itself. Stackoverflow has only one ticket open https://stackoverflow.com/questions/tagged/web3-onboard

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions