4. MobX in React
React for me is functions that render the user interface, and MobX is classes that hold the state of the application. In this chapter I'll show you how easy and powerful that connection is.
We'll build counters: a value and five buttons that change it. Then more counters, a limit, a sum and a field where you type the value. You need only two spells for that. The two Bonus lessons at the end keep the counters in the URL and in localStorage.
The finished app is mobx-example (demo). Its code is a little older than these lessons (deleteCounter, addOne), so use it as a reference, not as a starting point. In your own Vite project, MobX is one command away:
pnpm add mobx mobx-react-lite