quantified-uncertainty / metaforecast

Fetch forecasts from prediction markets/forecasting platforms to make them searchable. Integrate these forecasts into other services.
https://metaforecast.org/
MIT License
57 stars 5 forks source link

Avoid flashing on initial load #14

Closed NunoSempere closed 2 years ago

NunoSempere commented 2 years ago

Behavior: On initial site load, the site flashes. That is, the content is briefly shown, then it disappears, and then it's shown again.

Desired behavior: That doesn't happen.

You can see a video of this behavior on: https://imgur.com/a/hN50EhG

Steps to reproduce: Load a page you haven't searched for before on an incognito tab on Chrome.

berekuk commented 2 years ago

Oh. Looks like an issue with the way I used useEffect, it reloaded data on initial render.

Fixed with the custom useNoInitialEffect.

I also threw in nprogress bar, hope you'll like it :)

berekuk commented 2 years ago

Also, turns out I forgot to add shallow: true option to router.replace call, which caused double fetching (Next.js refetches getServerSideProps on navigation by default). Fixed this one too.

NunoSempere commented 2 years ago

Great, thanks!!