-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] Disconnect not persisting and reconnecting on page load #38
Comments
Seems like a this is a duplicate of #35 (as you noticed yourself in the "Edit"). For the solution: It normally should not prompt every time to connect again through MetaMask, since the connecting only needs to be established once. Could be an option in MetaMask? For me it is only asking once. |
I would expect though that if I call disconnect after reloading it should ask me to connect again and not assume I want to automatically connect with the last used account |
I thought it would work with autoConnect? This is a little misleading for you I think. If you want the desired behavior, you might want to implement ur own local storage, which is checking whether the user disconnected once in it's lifetime and set the autoConnect prop based on this local storage. |
@sammdec MM (and other injected providers) don't support programmatically disconnecting. I agree it's confusing to reconnect on page reload, but technically it's the most accurate since the account is still connected to the browser. (wagmi does handle disconnect events coming from connector directly. For example, disconnecting in MM UI.) That said, you could manage connection status separately in the browser, but you would need to listen and handle different connection events (i.e. disconnecting or switching account directly through MM extensions). |
Ah ok yeah that makes sense! Happy to stick what the most default behaviour is in that case |
This issue has been locked since it has been closed for more than 14 days. If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion. |
Is there an existing issue for this?
Package Version
0.0.17
Current Behavior
Using a Next.js app, Im calling the
disconnect
function from theuseAccount
hook. It does disconnect but then after refreshing the page it reconnects again and the account info re-populatesExpected Behavior
I would expect to be disconnected from ym wallet so that I may be able to reconnect again with a different wallet or simply use the site in its disconnected state
Steps To Reproduce
connected:true
.disconnect
function. -> useAccount returns empty data as expected andconnected: false
.connected:true
Anything else?
No response
Edit: It seems as though if I remove
autoConnect
prop on the provider then it does indeed keep me disconnected however that then means on every refresh I need to reconnect. Ideally I would like connect automatically until I explicitly call disconnectThe text was updated successfully, but these errors were encountered: