State management in ReScript, what solutions do you prefer?

What are the community’s preferred solutions for state management in react with rescript?

I have significant experience with react and typescript where I’ve found mobx-state-tree to be the most performant, usable, and productive state management solution, although it has some warts especially around typescript. One global tree of state that can only be mutated in specific action functions + implicit fine grained dependency tracking makes for great performance and ergonomics, almost no boilerplate.

Plain react state management has a lot of obvious problems that I don’t want to rehash here (states tied to component tree, boilerplate, lack of good async story, hard to do derived state, more inefficient as state is lifted to common ancestors, etc).

Redux and similar “simple” patterns IMO tend to suffer from boilerplate, performance issues (not fine grained enough about what must re-render), and don’t have great stories around non-trivial state transformations like async actions, fallible actions, retries, etc.

Are there any great state management solutions that really leverage ReScript’s capabilities? IMO good react state management should be capable of the following:

  1. Strongly typed
  2. Fine grained dependency tracking, only components relying on modified data get re-rendered on finalized state
  3. Minimal boilerplate
  4. Efficient derived state
  5. Support for async state changes
  6. Support for fallible / retryable state changes
  7. Takes into consideration error handling
  8. State decoupled from UI
  9. State is composable
  10. No string keys/identifiers, strong typing
  11. Support for serialization/deserialization
  12. Support for change tracking (patch stream and/or repayable actions)

Good state management is a complex thing! What are everyone’s preferred solutions in ReScript? Why? Thanks!

Hi @evelant here’s a previous thread that discusses state management. If you haven’t already seen it, maybe it has some useful insights for you?

1 Like