Course lesson
Cache a MetaMask Wallet Address in localStorage
Since we are storing the user’s wallet address in React state, it is lost when the dApp is reloaded. To fix this, we’ll cache the address in localStorage.
- Duration
- 2 min
- Access
- Included
- Transcript
- Retained from source evidence
Since we are storing the user’s wallet address in React state, it is lost when the dApp is reloaded. To fix this, we’ll cache the address in localStorage.
We’ll use the useEffect hook to look for an address in localStorage if there isn’t one in local state.