Live data from Hacker News

MobX – Simple, scalable state management for React

mobxjs.github.io

21–27 of 27 posts

Re: MobX – Simple, scalable state management for React

#21
I was able to rebuild a week's worth of Redux work in MobX within a day. And that's having never used it before.

What's crazy is how MobX is able to update React child components without updating the parent first. It knows which properties are accessed in each component, and ensures only the ones that rely on the changed data are updated.

I'd say give it a shot the next time you have a component with internal state. Not having to worry about the reducer or how the component gets updated is refreshing.

Re: MobX – Simple, scalable state management for React

#22
post #9

Earlier quoted context omitted.

> MobX is completely glitch free MobX looks interesting but I am a little concerned that you are claiming it is bug-free.

I don't believe he meant glitch in the sense of bugs but rather in FRP terms. I.e. temporarily inconsistent state.

yep that was the glitch I was referring to indeed :)

Re: MobX – Simple, scalable state management for React

#23
post #3

I wrote a very large app in Knockout back in the day, and ran into significant problems with Knockout's computeds and the two way data binding. It was great to start with, but as the app got larger and more involved, performance started to suffer (from all the different observables and computed triggering and retrigger on a change), memory leaks started to creep in, and eventually I started noticing weird glitches wh…

I have written a fairly big open source React + Redux application https://github.com/rwieruch/favesound-redux and refactored it to use MobX instead of Redux https://github.com/rwieruch/favesound-mobx I hope I can add some extra value to your post.

I agree that for most users Redux feels like a lot of boilerplate. At the same time I think most people underestimate were we came from. Personally I wrote a huge amount of Angular code before and at a certain point I felt very unhappy about the two-way data binding and state handling in Angular. It was unpredictable in a huge code base at some point. Then it was the time of Flux and in our company we introduced a stores and unidirectional data flow implementation of our own. Afterwards Redux got announced and we loved the clear constraints and lightweight API from the beginning. We use it now.

In a team of developers everyone can clearly follow state changes, the state itself and the places from where the state changes were triggered. Redux is scaleable and shouldn't be used for every small project which could live without a state management library and should use setState instead. Redux simply works, even though you have already a big amount of actions in production.

I think MobX is on the right path to give an alternative way for state management. For now I see a clear benefit to kick off smaller projects in smaller teams which don't rely on Redux' constraints and scaleability. Little feature op-tins like useStrict will help MobX to have a more scalable state management system. Otherwise in a growing code base it will feel like the old Angular days with two-way data binding. In the end that is the power of MobX, because it isn't opinionated: You can either mutate your state directly in a component or build a proper infrastructure around it to make it scale.

Re: MobX – Simple, scalable state management for React

#24

Mobx is a blessing ! I work on React only since a few months, I have a ton of subjects to learn, a ton of libraries to learn to how to use them. I really don't have time to learn a complex library like Redux. I tried, and learned its principles, but I soon saw that it would totally transform my existent codebase into a large cream cake with some boilerplate code everywhere. I come from Java world, which is often mock…

Redux isn't complicated, it is the ecosystem around it which can be overwhelming or partly overengineered.

When you get started with React, you should use setState. You should use it until you get the feeling you really need a state management library to deal with most of the setState implementations. That removes the urge to learn another library next to React in the beginning.

Afterwards I agree: MobX is easier at the start, because it can be used similar like setState https://medium.com/@mweststrate/3-reasons-why-i-stopped-usin...

But at some point the developer team might decide to use MobX' useStrict to have more explicit actions and more predictable state changes. It removes the feeling of having two-way data binding and after all goes in the direction of the Redux constraints.

Re: MobX – Simple, scalable state management for React

#25

Online courses: Introductoin by LearnCode.academy: https://www.youtube.com/watch?v=_q50BXqkAfI More in depth: https://egghead.io/courses/manage-complex-state-in-react-app...

Adding some more:

Refactor a Redux Application to use MobX http://www.robinwieruch.de/mobx-react/

Large MobX React Application https://github.com/rwieruch/favesound-mobx

Re: MobX – Simple, scalable state management for React

#26
post #3

I wrote a very large app in Knockout back in the day, and ran into significant problems with Knockout's computeds and the two way data binding. It was great to start with, but as the app got larger and more involved, performance started to suffer (from all the different observables and computed triggering and retrigger on a change), memory leaks started to creep in, and eventually I started noticing weird glitches wh…

I have written a fairly big open source React + Redux application https://github.com/rwieruch/favesound-redux and refactored it to use MobX instead of Redux https://github.com/rwieruch/favesound-mobx I hope I can add some extra value to your post. I agree that for most users Redux feels like a lot of boilerplate. At the same time I think most people underestimate were we came from. Personally I wrote a huge amount of…

Wow, your project looks great! I will be using it for inspiration in the future for mobx!

Re: MobX – Simple, scalable state management for React

#27

I was able to rebuild a week's worth of Redux work in MobX within a day. And that's having never used it before. What's crazy is how MobX is able to update React child components without updating the parent first. It knows which properties are accessed in each component, and ensures only the ones that rely on the changed data are updated. I'd say give it a shot the next time you have a component with internal state.…

> It knows which properties are accessed in each component, and ensures only the ones that rely on the changed data are updated.

This is what blew me away. I understood that "computed" values were doing this, but when I saw that the react components were using it as well, I was sold. I have been in componentWillReceiveProps with redux too much, trying to improve rendering performance. With mobx, out of the box, you get 100% exact render updating.

Post reply on HN