merisbahti / klyva

A state management library that follows the React component model
MIT License
55 stars 4 forks source link

Fix removal of sliced atoms #7

Closed merisbahti closed 3 years ago

merisbahti commented 3 years ago

This is due to that, for example when an Atom<string[]> is being sliced, if the parent, that slices the atom, removes an item which one of the sliced atoms points to, then when the child recalculates its value, it will get an undefined reference. But React unsubscribes to the value first, so it doesnt matter.

This is due to that the parent, which is slicing the atoms, always "unmounts" the child before the child needs to recalculate its value, and its only in this recalculation the error happens - but it does happen.

I wasn't able to reproduce this in test cases unfortunately.