Address of the account doesn't save

Hi!
The problem I have is that after reload the page value account from useMoralis() doesn’t save.
I was looking at an example of ethereum-boilerplate and at the top right corner my address always shows despite reload the page.
https://ethereum-boilerplate.github.io/ethereum-boilerplate/quickstart

My code:

import { useMoralis } from "react-moralis";

function App() {
  const { isAuthenticated, user, account} = useMoralis();
  console.log(account)
  if (!isAuthenticated  || !account) {
    return (
      <div>
        <button onClick={() => authenticate()}>Authenticate</button>
      </div>
    );
  }
  return (
    <div>
      <h1>Welcome {user.get("username")}</h1>
      <h2>your account address is {account}</h2>
    </div>
  );
}

export default App;

Did you try with useEffect?

Hi @Artemida
Can you elaborate your question a bit what are you trying to achieve?
AFAIK from reading your question are you trying to save account address in DB? or is it not showing in your page?

Yes I tried but it doesn’t work

I want that it wil be like in ethereum-boilerpalte example (https://ethereum-boilerplate.github.io/ethereum-boilerplate/quickstart)
Where my account address always to be shown. Even after reloading page. My problem is that after reloading the page I have to again do authenticate() because my account from UseMoralis() is equal null

You can also try to use enableWeb3, but somehow it should be easy to get the account from current user

Ye it helped me at half, now I always have account but still It works strange.
I added this code

useEffect(() => {
     if (isAuthenticated && !isWeb3Enabled && !isWeb3EnableLoading) enableWeb3();
  }, [isAuthenticated, isWeb3Enabled]);

So I don’t have to authenticate() again, after reloading the page. But if I use my app like the first time
isAuthenticated is true, it triggers enableWeb3() and I have to do registration, despite I use app the first time and isAuthenticated has to be false

you could try:

useEffect(() => {
     if (!isWeb3Enabled && !isWeb3EnableLoading) enableWeb3();
  }, [isWeb3Enabled]);

Hello, someone has an updated version of the code ?
Trying to use:

useEffect(() => {
     if (!isWeb3Enabled && !isWeb3EnableLoading){
return(
....rendering the button to connect with Modal
);
    }
  }, [isWeb3Enabled]);

and

useEffect(() => {
     if (isAuthenticated && !isWeb3Enabled && !isWeb3EnableLoading){

return (

....rendering the button to connect with Modal

);
  }, [isAuthenticated, isWeb3Enabled]);

but it does not “render” the button… trying to use https://github.com/giovannibenussi/use-persisted-state-hook, but fail to keep the “session” and not the “wallet” within a var.

Thanks