Infinite Loop (React Error 185) with useQueryStates + localStorage Wrapper #1179
Unanswered
codingwithdidem
asked this question in
Q&A
Replies: 1 comment
-
|
It's kind of hard to wrap your head around the whole thing, but I think this could be a source of issues: isUpdatingRef.current = true;
try {
// ...
const result = await setQueryStates(value);
return result;
} finally {
isUpdatingRef.current = false;
}Since the Promise returned by nuqs' state updater functions resolves once the URL has been updated, and this depends on the state of the throttle queue, this could be the source of your hard-to-reproduce race conditions. If you're only tracking the internal optimistic state update, that one is synchronous. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Issue
Getting "Maximum update depth exceeded" (React Error 185) in production and app crashes with client side error message when users navigate to our meetings page perform searches or paginate to another page. The error is extremely difficult to reproduce locally and on production (Only some of the users able to reproduce multiple times a day), suggesting it only occurs under specific race conditions. I'm not sure if its OK to use nuqs with localstorage any help is appreciated
Setup
We created a custom hook that wraps
useQueryStatesto sync URL params with localStorage for persistent filters:Custom Hook Structure:
Usage In Another Hook:
Finally our searchbar:
Environment: nuqs 2.4.3, React 19.1.0, Next.js 15.4.7 (App Router)
Beta Was this translation helpful? Give feedback.
All reactions