Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum update depth exceeded on 8.0.0 #166

Closed
hilmia opened this issue Sep 17, 2023 · 19 comments · Fixed by #177
Closed

Maximum update depth exceeded on 8.0.0 #166

hilmia opened this issue Sep 17, 2023 · 19 comments · Fixed by #177

Comments

@hilmia
Copy link

hilmia commented Sep 17, 2023

Getting the following error in V8.0.0

Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

Running on NextJS

@justin-schroeder
Copy link
Member

Will need a reproduction to proceed with any debugging.

@francolorenzocarestino
Copy link

francolorenzocarestino commented Sep 19, 2023

The same problem with useAutoAnimate on:
"react": "18.2.0",
"next": "13.4.19",
"@formkit/auto-animate": "^0.8.0",

@justin-schroeder
Copy link
Member

Can you create a stackblitz reproduction?

@francolorenzocarestino
Copy link

I think it has to do with the optional configuration.
this gives me error:
const [parent] = useAutoAnimate({ duration: 150 })
and not this:
const [parent] = useAutoAnimate()

@francolorenzocarestino
Copy link

Can you create a stackblitz reproduction?

Yes, I try it

@jhubbardsf
Copy link
Contributor

jhubbardsf commented Sep 19, 2023

Just wanted to mention I'm getting this too when trying to add an optional plugin. Doesn't occur when using plain useAutoAnimate().

react: 18.2.0
next: 12.2.0
autoAnimate: ^0.8.0

Edit: @justin-schroeder Updated with stackblitz showing the error. (link)

@kenzaflow
Copy link

I think it has to do with the optional configuration. this gives me error: const [parent] = useAutoAnimate({ duration: 150 }) and not this: const [parent] = useAutoAnimate()

The same here, fixed by removing params

@cvpcasada
Copy link

Memoizing the optional configuration (or making the object reference constant) seems to fix the issue on my end.

@justin-schroeder
Copy link
Member

If anyone wants to submit a PR to fix this I’d happily merge/publish it. Otherwise, this will be at the mercy of whenever I get the time to do another sprint on AutoAnimate — probably a few weeks aways.

IvarssonAndreas added a commit to IvarssonAndreas/auto-animate that referenced this issue Oct 8, 2023
@mehmetakifakkus
Copy link

Making version of the auto-animate down to 0.7.0 resolves the problem on my end. I also do not use the params fed to constructor.

@jhubbardsf
Copy link
Contributor

Memoizing the optional configuration (or making the object reference constant) seems to fix the issue on my end.

If anyone needed an example of how to memoize an optional configuration and see it working:
https://stackblitz.com/edit/stackblitz-starters-nkqz3q?file=pages%2Findex.js

justin-schroeder added a commit that referenced this issue Nov 3, 2023
Fix Max update depth exceeded with useAutoAnimate
@verheyenkoen
Copy link
Contributor

Any release planned?

@jhubbardsf
Copy link
Contributor

jhubbardsf commented Nov 4, 2023

@verheyenkoen You might already know this, but figured I'd post this in case someone else needed this bug fix before their next release. You can choose to install the library from the master branch of this repository instead of a release version. Run the following command. It will install build and install @formkit/auto-animate from the specified branch. If you already have @formkit/auto-animate in your package.json that's fine, it'll update it to point to this master branch.

npm i formkit/auto-animate#master

I believe this should work with yarn and pnpm as well.

Note: Notice I didn't type npm i @formkit/auto-animate#aster, there's no @ namespace before formkit. This is because npm will search for the formkit/auto-animate repository, not the @formkit npmjs namespace.

@justin-schroeder
Copy link
Member

This fix is now published in 0.8.1

@stefanofa
Copy link

I am not completely sure that the merged fix represents the intended behaviour.

With the new change, it will no longer be possible to systematically update the options used by autoAnimate, and only the options set when the component was mounted using useAutoAnimate will always be used.

Maybe these are niche cases, but it becomes impossible1 to change the easing or the duration systematically.

Footnotes

  1. or very complicated and counterintuitive as one would have to remount the component using useAutoAnimate by manually changing the key

@melonges
Copy link

melonges commented Dec 3, 2023

This problem remains

    "next": "13.5.4",
    "react": "18.2.0",
    "@formkit/auto-animate": "^0.8.1",

@HaynesX
Copy link

HaynesX commented Jun 3, 2024

Not working for me on Next.js with 0.8.2 still, using NextUI\s Listbox.

@strblr
Copy link

strblr commented Jun 8, 2024

Same problem here. Using React 18.3.1

@algoORgoal
Copy link

algoORgoal commented Jun 25, 2024

Same problem here, using Next.js 14.2.3
@justin-schroeder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.