Prevent rerenders with useShallow
When you need to subscribe to a computed state from a store, the recommended way is to use a selector.
The computed selector will cause a rerender if the output has changed according to Object.is.
In this case you might want to use useShallow to avoid a rerender if the computed value is always shallow
equal the previous one.
Example
We have a store that associates to each bear a meal and we want to render their names.
Now papa bear wants a pizza instead:
This change causes BearNames rerenders even though the actual output of names has not changed according to shallow equal.
We can fix that using useShallow!
Now they can all order other meals without causing unnecessary rerenders of our BearNames component.