OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

React-Zustand able to mutate state without set()

  • Thread starter Thread starter Ishank Gupta
  • Start date Start date
I

Ishank Gupta

Guest
I have a CodeSandbox which shows the issue I am running into with a complex web app I am working on:

Three components show the same array from the store When I sort the array in one of the components, it affects the array in all components for some reason. This should not be possible because I believe the store cannot be updated unless we use set(). How can I avoid this? Someone accidentally sorted an array from the store and it affected the whole app

<p>I have a <a href="https://codesandbox.io/p/devbox/xf9k3n?file=/src/main.jsx:11,1" rel="nofollow noreferrer">CodeSandbox</a> which shows the issue I am running into with a complex web app I am working on:</p>
<p>Three components show the same array from the store
When I sort the array in one of the components, it affects the array in all components for some reason. This should not be possible because I believe the store cannot be updated unless we use set(). How can I avoid this? Someone accidentally sorted an array from the store and it affected the whole app</p>
 

Latest posts

Top