Jump to content
Search Community

Maximum call stack size exceeded by observer

TruongNH test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi, I have some trouble with my Observer. 


I used it to snap between 2 sections. I have a state for the open menu is isOpenedMenu and pass it to the navbar as props. But when I click many times it causes an error with the Observer. I'm going crazy over this because when stated in the navbar component it works normally. What's wrong with the Observer?

Here is my codesanbox: Maximum call stack size exceeded by observer - CodeSandbox

Please support me, 
Thank you so much 

Link to comment
Share on other sites

  • Solution

Ah, it looks like this exposed an odd condition where if you call gsap.registerPlugin(Observer) multiple times, it could throw an error. That should be fixed in the next release, but it's easy to work around in your demo by just making sure you only call it once - right now you've got it inside your App() function so just put it outside of that so it doesn't get called every time that component re-renders: 

https://codesandbox.io/s/maximum-call-stack-size-exceeded-by-observer-forked-mm68pn?file=/src/App.js

 

Better? 

Link to comment
Share on other sites

On 11/13/2023 at 4:36 AM, GreenSock said:

Ah, it looks like this exposed an odd condition where if you call gsap.registerPlugin(Observer) multiple times, it could throw an error. That should be fixed in the next release, but it's easy to work around in your demo by just making sure you only call it once - right now you've got it inside your App() function so just put it outside of that so it doesn't get called every time that component re-renders: 

https://codesandbox.io/s/maximum-call-stack-size-exceeded-by-observer-forked-mm68pn?file=/src/App.js

 

Better? 

I got it. Now it's better. Thank you so much.

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...