Error: Maximum update depth exceeded in NEXTJS #2771
Unanswered
Arghyahub
asked this question in
Bug report
Replies: 1 comment 5 replies
-
Please try this: const { User, setUser, setSomeUser } = useUserStore(useShallow((state) => ({
User: state.User,
setSomeUser: state.setSomeUser,
setUser: state.setUser,
}))); |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug Description
In Nextjs importing states like this causes an error where react goes into recursion and crashesh
Store
Component
Importing in this way causes the problem but importing it like
const User = useUserStore(state => state.User)
works fine.Complete error:
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.
Reproduction Link
Beta Was this translation helpful? Give feedback.
All reactions