3 ms·
>Can someone explain this in a little more detail? Particularly the eschewing the lifecycle altogether. We use it in conjunction with MobX observers, so that a
by aphextron 6y ago
>Can someone explain this in a little more detail? Particularly the eschewing the lifecycle altogether.
We use it in conjunction with MobX observers, so that a component is only ever rerendered when its' data is updated, and there's no fooling around with `componentDidUpdate` stuff that can get unwieldy really fast.
The interaction flow is basically: Click handler -> Send event to the state machine -> State machine evaluates business logic, calls services, etc. and updates MobX model -> MobX observer rerenders the pure functional React component. So that all your components are ever doing is sending events to the state machine, with no business logic baked in. Use `useState` for ephemeral component level state like toggle switches, but the source of truth for the entire application lies in MobX models updated by state machines.