Trying to update a value at index in a store array, updates all elements
Hello everyone, I'm sorry this is probably gonna be a bit long, I'm having a hard time trying to explain myself.
Here is my issue: I'm working on an app using a context, and inside this context there is a store. I did like in the stores_context tutorial: I have a function that initializes a store, and returns it with some setter functions to update it. I have a useContext() function that returns the whole thing and it works. The store contains an object that contains an array of objects, and I'd like to update an attribute of the object at an index of the array. But when I call the function, the value is updated at all indexes, it seems. And this happens in the app only ; I have an unit test (with vitest) which calls exactly the same function, but it works fine and only the object at the right index is updated.
I put the (very simplified) code in an attached file, I hope it worked. It's the function "setAttributeAtIndex" that causes issues. I've been console.logging it, it's called only once with the right index, I'm logging the context before and after the setMyContext. Right after the call, all of the indexes have been updated
I also tried to change my setters and use the produce function, but it did exactly the same. I've been stuck on this for a while now, does anyone see something that I'm doing wrong? What should I do?
Thanks a lot for your attention, I wish you a nice day!