Using Valtio and MobX
Although the motivation is quite different, Valtio is often compared to MobX (https://mobx.js.org). Usage-wise, there are some similarities in Valtio and MobX regarding their React binding. Both are based on mutable states and developers can directly mutate state, which results in similar usage. JavaScript is based on mutable objects, so the syntax of mutating an object is very natural and compact. This is a big win for mutable states compared to immutable states.
On the other hand, there is a difference in how they optimize renders. For render optimization, while Valtio uses a hook, MobX React uses a higher-order component (HoC): https://reactjs.org/docs/higher-order-components.html.
In this section, we will convert a simple MobX example into Valtio. Then we will see the differences between the two.
Important Note
Conceptually, Valtio is comparable to Immer (https://immerjs.github.io/immer/). Both try to bridge immutable and mutable states. Valtio...