Uncaught Error: Maximum update depth exceeded (implementing Tic Tac Toe Example from the docs) #2864
Replies: 3 comments
-
@venkatmidhunmareedu my bad I need to update the tutorial to be compatible with v4 and v5, but in a nutshell we need stable selector results, we have two options: this one const squares = useGameStore(state => state.squares)
const setSquares = useGameStore(state => state.setSquares) or this one using const [squares, setSquares] = useGameStore(useShallow((state) => [
state.squares,
state.setSquares,
])) on v4 and v5 no stable selector results could cause performance issues, on v4 that is not optimized and could hide some issues but does not mean that does not happen on v4, on v5 that is more visible |
Beta Was this translation helpful? Give feedback.
-
Hey @dbritto-dev , Thanks for helping out.
worked out for me. As for the second one, Their are two types of useShallow i can find.
Second one:
Both of them worked for me. But why two? But once you manually type any of above two import statements, it recognizes: As for the discussion #2204, it is said that this would be resolved in version 5. |
Beta Was this translation helpful? Give feedback.
-
@venkatmidhunmareedu interesting I'll look into that |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am new to zustand. I was trying out the Tic Tac Toe implementation from the docs. I just copy pasted the useGameStore function from the docs page : https://zustand.docs.pmnd.rs/guides/tutorial-tic-tac-toe#lifting-state-up
and i got this Error:
The actual code i have written for your reference:
My dependencies:
Please help. I am new to state management and a newbie trying to learn
Beta Was this translation helpful? Give feedback.
All reactions