Add disconnect functionality to App component
- Introduced a disconnect button that removes the wallet from localStorage and reloads the page when clicked. - Updated the rendering logic to conditionally display the connect and disconnect buttons based on the connection state.
This commit is contained in:
1 parent
8d69cd3d3f
commit
f46a4418c9
1 file changed
+6
-2
+6
-2
@@ -22,11 +22,15 @@ function App() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const disconnect = async () => {
|
||||||
|
localStorage.removeItem('VARAN_WALLET');
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}>
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}>
|
||||||
<button onClick={connect}>Connect</button>
|
{isConnected && <button onClick={disconnect}>Disconnect</button>}
|
||||||
|
{!isConnected && <button onClick={connect}>Connect</button>}
|
||||||
<div>Is Connected: {isConnected ? 'Yes' : 'No'}</div>
|
<div>Is Connected: {isConnected ? 'Yes' : 'No'}</div>
|
||||||
<button onClick={checkData}>Check Data</button>
|
<button onClick={checkData}>Check Data</button>
|
||||||
<div>DATA</div>
|
<div>DATA</div>
|
||||||
|
|||||||
Reference in new issue
Block a user