React + MobX Crash Course
React + MobX Crash Course
State management in React apps can be a hard thing to do. Are you having a hard time
wrapping your head around React state management, and getting tired of writing
boilerplate for Redux? Let's check out MobX - everything becomes so simple and
effortless
1 - MobX Concepts
MobX is a "reactive" state management library.
We directly mutate the state. Because we use MobX to observe and track mutations, the
UI will be auto-updated, like cell updates in Excel. Network requests can also auto-send
when conditions are met.
Everything is automatic!
4. Reactions
We can use autorun() or when() to watch observables and perform effects when there's
update:
• autorun() takes a callback and runs it each time any observable used in it gets
updated. (Remember to do the clean-up!)
• when() only runs the callback once, when a condition is met.