Jump to content
Search Community

ScrollTrigger in nextjs build not working reliably

andiwi test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

@willthomson that definitely sounds wrong to me. useGSAP() uses the useIsomorphicLayoutEffect internally, and it also handles cleanup automatically. If you just use the useIsomorphicLayoutEffect() directly instead of useGSAP(), you are probably skipping proper cleanup which is not a good idea. 

 

If you're having trouble, would you please provide a minimal demo, like a Stackblitz? Here are some starter templates: 

https://stackblitz.com/@gsap-dev/collections/gsap-nextjs-starters

 

You're using the latest version of GSAP too, right? 

Link to comment
Share on other sites

1 hour ago, willthomson said:

@JPPdesigns Did you ever find a solution to solving this in Dev Mode? 

I'm running into the same issue where my production next builds work fine but they jump way down the page in dev mode.

Nah mate, just living with it... knowing it will be fine in prod. It's only nextjs. I use Storybook as well and all good there. Something with NextJS internals me thinks.

Link to comment
Share on other sites

Hi @willthomson and welcome to the GSAP Forums!

 

It shouldn't matter if you use useIsomorphicLayoutEffect or useGSAP. The useGSAP hook actually uses that under the hood:

https://github.com/greensock/react/blob/main/src/index.js#L14

 

There shouldn't be any issues with using the useGSAP hook neither in development nor production environments. It'd be good if you could create a minimal demo that clearly illustrates the problem you're facing, just remember to keep the demo as small as possible.

 

Happy Tweening!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...