Skip to content

New Coding Manual

alisman edited this page Feb 27, 2023 · 9 revisions

State Management

Mobx philosophy

Single source of truth. Everything that can be computed, should be computed, and in such a way that it will automatically recompute when its underlying inputs change.

Store state vs component state Keep data/state/derived computations that are shared across features of an application in a global page store. Put feature specific and ephemeral state in "local" component state.
API loaded data should almost always be kept in global stores.

We need to come up with a better way to break up massive stores into smaller stores of concern. This is not trivial.

Class components need to call makeObservable in constructor in order to make observable decorators kick in (this is due to a change in js decorator implementation).

In functional components, we can achieve local observable properties and computed getters using the useLocalObservable hook.

React component style

Class components vs Functional (w/ hooks)

CSS

CSS modules

Functional programming style

Chaining with lodash

Data loading and loading status

MobxView MobxPromise Facade promise

Clone this wiki locally