Closed sebastiangraz closed 2 years ago
Hey there @sebastiangraz thanks for the kind words, glad you're digging hull!
As for the eslint warning/issue you outlined:
I'm not sure exactly why this useEffect
would cause your logs to loop simply by adding the context hook for togglePageTransition
. That's totally separate from the useScrollRestoration
hook.
I agree that the scroll restoration stuff is exhaustively complicated to do something inherently simple and obvious. Unfortunately this seems to be a side effect of Next.js for a lot of people, and this was the only solution that seemed to cover 99.99% of edge cases.
In any case, for some context: the useEffect
you outlined above doesn't have any dependencies because we only want it to run once on the client to setup our router events. I know eslint can get weird about this, but I think telling it that this is "ok" is a fine work-around for now.
FWIW though: We're working on refactoring the entire _app.js
to be a bit cleaner and move some of these client-side effects to their own, self-contained wrapper components ✨
This should make this a non-issue once we roll that out, so stay tuned! 🤘
Love the repo, very helpful in getting started with Nextjs+Sanity. The other night I found that my linter recommended to supplying the
useEffect
dependencies inside theSite
component. With the goal of being able to deploy easily without any errors I addedtogglePageTransition
as a dep and the site started looping all my console.logs into the tens of thousands, depending on how far I scrolled. So definitely seems like there is something going on with the scroll restoration.Either way its not a huge deal as I can just comment out the linter error and it'll deploy fine, but just wanted to let you guys know if you weren't aware. I do wonder though if there is a cleaner way to get the desired scroll restoration without having to comment out erroneous parts of the code.
Cheers