Working with mobx#
mobx as its state manager on top of React's state management system.
This helps with having a more declarative style of managing state, as opposed to
You should already have a basic understanding of how
React handles state (read here for more information).
However, if you do not, here is a quick overview.
React.Componentis generic over both
State(with default empty object types).
Propsshould be considered read-only from the point of view of the component and is the mechanism for passing in "arguments" to a component.
Stateis a component's internal state and can be read by accessing the parent field
Statemust be updated using the
setStateparent method which merges the new data with the old state.
Reactdoes do some optimizations around re-rendering components after quick successions of
How mobx works:#
mobx is a package that provides an abstraction over
React's state management. The three main concepts are:
observable: data stored in the component's
action: a function that modifies any
computed: data that is derived from
observable data but is not actually stored. Think of this as computing
isEmpty vs an
observable field called
Further reading is available from