xoid makes it easier to work with nested state. Redux and React are both based on immutable updates. Immutability is great, but it can easily "reduce" developer experience. (See? 🤣) One of the most significant by-products of immutable updates is the excessive usage of the spread operator to copy objects and arrays.
Here's a typical nested state update that you can stumble into in a React component or a Redux reducer.
Writing this is effortful, it's easy to make mistakes, and reading it is painful. To overcome this, tools like immutablejs or immer is being used. Even Redux Toolkit comes with immer by default. Note that using Redux toolkit means adding another ~11kB to your bundle size. This number is ~5kB for immer alone.
use function, xoid (~1kB) doesn't require any additional library to simplify nested updates. The following is simply equivalent to the above example:
To see how xoid compares to a classical reducer, and a dedicated library that's using immer internally, you can check the following example: