NextJS ReactJS data disappear while authenticating

Hello, I’ve got a question… Why does data disappear when I’m trying to authenticate? I’ve got some data displayed on the dashboard that didn’t require to be logged in/authenticated, when I’m trying to authenticate using MetaMask the data disappear… I’m working on Next.js (React.js), I’ve tried that on a pure new project without anything, the only things are some data displayed and button to log in and still it disappears when I try to auth and after auth… I was trying some double if statement like {authenticated ? displayData : displayData} or with isInitialized and initializing, authenticating. Any ideas? Thanks

The data is token balance taken from some static address on BSC (staking), when you open the website it shows up, but when you try to auth it disappears.

notnice

If you are fetching for a static address, try push it into a separate state and use the result from the state to display your data.

1 Like

Another thing would be, why does data disappear after refreshing the page, it shows only on server restart/saving project, the only thing to access that data is to .map this inside component return, only here it stays, but if I would want to make a function outside or anything it disappear I had to do something like that, I’ve spent over a day to fix that

I was doing that, it doesn’t help. On refresh it also disappear, because it push an empty array then… But I guess I would try to make a function that push it only once when data appear and then stop pushing if data === null

sobad

After refresh

You can make it data?.filter instead of data.filter

1 Like

Ok thanks <3 I see that I should store any data from Moralis in a smart way