Has anyone experience with MobX? And could you tel...
# orm-help
m
Has anyone experience with MobX? And could you tell me if you prefer it over Redux?
t
Yes I have! We're using it in the new Console. It is definitely way simpler, but includes a lot of magic. Data flows are not clear. So you might look into mobx state tree. But for a small or medium sized project with not too crazy data dependencies, mobx is a great choice if you need state across components.
And the old Redux: If you use tools like
redux-action
or
redux-saga
, you can build clean architectures that scale. An example is the playground: https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-react/src/state
j
I don't know exactly what is your use case, but you could be also interested to have a look into React Context (https://reactjs.org/docs/context.html) and Apollo for local state management in case you want to use GraphQL (https://www.apollographql.com/docs/react/essentials/local-state.html).
w
I think in most of the cases, using Redux is overkill. Most of your stuff can be done using pure React, and when you come at a point where you can’t handle it anymore without a state-management library, then MobX is in most of the cases the way to go. If you handle things properly with vanilla React, then you’ll probably end up with only a few cases to handle with a store, and MobX will be perfect for that thanks to its quick setup and boilerplate-free api. IMO, Redux should only be used in very large project that need a solid architecture. Redux only adds useless complexity in most of the projects