Autorun works by running the effect in a reactive context . During the execution of the provided function, MobX keeps track of all observable and computed values that are directly or indirectly read by the effect.
Read moreWhat is observable in MobX?
observable defines a trackable field that stores the state . action marks a method as action that will modify the state. computed marks a getter that will derive new facts from the state and cache its output.
Read moreHow do you compute in MobX?
Computed values can be created by annotating JavaScript getters with computed . Use makeObservable to declare a getter as computed. If you instead want all getters to be automatically declared as computed , you can use either makeAutoObservable , observable or extendObservable .
Read moreCan you use Hooks with MobX?
Hooks to the rescue. React Hooks are most likely the easiest way to consume MobX store . They give you a freedom in how to do things instead of heavily opinionated inject .
Read moreDoes MobX work with functional components?
In this tutorial, we will learn how to use MobX with React Functional Components . MobX being a very useful state management library reduces the code that needs to be written for global state management. Mobx is easy to use and quick to learn.
Read more