React problem - I can't refresh page after Metamask popup

Hi Guys,
I’m working on a decentralized blog. I’m facing a problem that I don’t undestrand how to resolve.
My app works correctly but I’m fighting to figure out how to refresh the page after metamask popup.
In fact after that, the new post doesn’t display and I need to refresh manually.

I tried to set some dependencies in useEffect but it didn’t work.

Here my code: https://github.com/kabelSalat17/Decentrablog/

I’d would be very happy if someone could help me.

Thanks in advance

1 Like

Hello sir, I have moved your topic to the proper category, so the community can reach your questions easily.

If you have any more questions, please let us know so we can help you! :slightly_smiling_face:

Carlos Z.

Hi @CryptoMat,

You can make the useEffect run when a particular variable changes. useEffect provides us with that functionality.
After you finish the meta mask operation, you can set a state variable such as “success=true” and then use that success state in useEffect to rerender the component.

Please refer to the article here – https://daveceddia.com/useeffect-hook-examples/#:~:text=By%20default%2C%20useEffect%20runs%20after%20every%20render%2C%20but%20it’s%20also,changed%2C%20the%20effect%20should%20rerun.

Hope this helps. :smile:

1 Like