Closed sekaiking closed 2 years ago
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/curaos/frontend/VHTKzws13s2Vy2Z8ux1wLUXx15Dr
✅ Preview: https://frontend-git-randomhome-curaos.vercel.app
Component doesn't update correctly, not sure why it happens but my guess it's something to do with NextJs cache
@achrafismyname Could you look into what's happening? Cause locally it works fine, it's just when it's deployed on Vercel that gives problems. The version you pushed is not optimal as it at always shows the first slide before jumping to the random one.
Ok, I'll look more into that
https://github.com/vercel/next.js/issues/10608
The only solution is to use useEffect
or disable SSR
Instead of showing the first slide, i'll put a loading animation. Hopefully this makes it look better
I removed the slide, until we random the first project slide.
I don't know if SEO matters in this project, but the projects in this page can't be crawled because they are all browser rendered. Before we had 1 project that can be seen by crawling bots, after this change zero can be seen.
As said in that issue linked:
Generally I'd just recommend not randomly shuffling stuff in the UI
I think there could have been a better solution here in general, but it's a minor adjustment and the homepage will probably have more iteration in the future. Let's merge it! 😄
The reason I randomized the project page inside
useEffect
instead of doing it directly inuseState
is that Image Component doesn't update correctly, not sure why it happens but my guess it's something to do with NextJs cache.useEffect
makes sure to change the page only after the component is settled.