6 ms·
I shudder at the complixity of Redux. Ooh~ nice, you dispatch an action to a reducer, ooh~. ~job security~ I don't know, it rubs me the wrong way when there ar
by sergiotapia 10y ago
I shudder at the complixity of Redux. Ooh~ nice, you dispatch an action to a reducer, ooh~. ~job security~
I don't know, it rubs me the wrong way when there are better tools out there. Mobx, is much quicker to integrate and is easier to understand how to integrate anywhere in a React app. Glad to see I'm not the only one who really doesn't like Redux.
I mean check it out, it has an incredibly small API, and even smaller if you use the right Webpack loaders.
import { observable, observe, toJS } from 'mobx'
export default class Store {
@observable foo = []
}
Then in your components just set or read from `this.context.store.foo`. Every component using the same store will update it's reference to foo.
https://sergiotapia.me/using-mobx-and-react-to-build-an-instant-search-3eae1dd20cbd#.2d0j5dbqa https://sergiotapia.me/using-mobx-and-react-to-build-an-inst...
- ergothus 10y agoAs someone that has recently started using Redux over Flux, how does Mobx handle nested dependencies? e.g. when you change selected item in store 1, it will impact items in store 2. (Redux doesn't have a great solution to this - it puts it all in the action handler - but it is consistent and means you components don't need to understand any of the store logic.)
- hugozap 10y agoYou can have a computed field in store 2 that computes the items based on the observable item in store 1, Whenever item 1 changes, the computed observable is updated automatically
- rlp 10y agoI agree, MobX felt much more natural to me when dealing with CRUD-style apps, there was very little boilerplate. Redux is great for apps with extremely complex workflows, but that's fairly rare in my experience.
- Waterluvian 10y agoRedux is like 200 lines of code and very explicit without any magic. What exactly is complex about it? I think too often people don't appreciate that redux, like all frameworks is a trade-off and is often the wrong tool for the job. Speaking about it as if it's a generic framework to trade out for another framework is a sign that it's being selected for the wrong reasons. If it's not making your life easier, you probably shouldn't be using it for that application. It's a really nice framing hammer, not a multitool ;) When I got into front end, I used redux for a small SPA with about a dozen actions and didn't really get it. "I could do this with react and basic JavaScript. Why am I writing so much extra?" I refactored redux out and it was much better. I have another application that interfaces with a number of APIs, is a very thick client and needs to recover from local storage on startup. Redux fit like a glove!
- cnp 10y agoI think a lot of the complexity comes from the incredible specificity of the docs. The authors intend to _teach_, which while great (thank you) it can seem overly complex for users who first land there. I think a "Quick Start" section would solve a lot of the so-called "complexity" issues, showcasing a few common use-cases: - Without React - With React Put bare-bones code under each of those sections and then let the user learn the particulars as they come (and as their projects demand)
- jaredsohn 10y agoWithout Redux - With Redux
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- acemarke 10y agoI'm currently the primary maintainer doing stuff with Redux docs. Right now my focus is on a tutorial series I'm writing for my own blog, but any PRs to help improve the Redux docs are absolutely appreciated!
- kasbah 10y agoThe only bit of Redux I actually use is `createStore`, `store.dispatch`, `store.getState` and `store.subscribe` but it seems stupidly simple to me. I sometimes start re-implementing a bit of it rather than pull a dependency in or if I am working in a language that doesn't have it as a library. This "Redux in a nutshell" implementation might illustrate better what I mean: https://gist.github.com/MarcoWorms/30758235f05faec844b8c06ce2e5bac9 https://gist.github.com/MarcoWorms/30758235f05faec844b8c06ce... React-Redux does seem to complicate things for no reason. I have just been using plain Redux with React because I didn't want to learn it.
- acemarke 10y agoAh... out of curiosity, what about React-Redux seems complex? Quick summary: - Wrap your component tree in <Provider store={store> - For any component that needs to access data or dispatch actions, use `connect()(MyComponent)` to create a wrapped-up version. - Write a function known as "mapStateToProps", and pass it as the first argument to `connect()`. It will be called every time an action is dispatched, and given the latest store state. Extract whatever pieces of data this component needs, return them, and they become props for the wrapped component. Dan Abramov wrote a miniature version of `connect` , which shows the basic approach it uses: https://gist.github.com/gaearon/1d19088790e70ac32ea636c025ba424e https://gist.github.com/gaearon/1d19088790e70ac32ea636c025ba...
- kasbah 10y agoI guess I just don't understand the "why" so I am not motivated to look into it properly and at first glance it's introducing loads of new concepts. Maybe as my apps get more complicated I'll outgrow it but just plain Redux seems fine for me at the moment.
- adregan 10y agoThe hands down best reason to use react-redux is because if you use `mapStateToProps` and `mapDispatchToProps` you can keep your connected components 100% dumb (I like to export both the dumb version and the connected as the default). This way, when using something like react storybooks or and in your tests you don't have to mock your whole the redux world.
- bschwindHN 10y agoIt rubs me the wrong way when someone uses JS instead of ClojureScript. And I bet someone could reply to me saying it rubs them the wrong way when I use that instead of Elm. There are always going to be alternative tools out there at different timelines. Projects get started at various times when certain tools are popular, and people have varying opinions of what the "best" one is. It's better to focus on making a good product because your users don't give a shit if you used Redux or Mobx.
- hackerboos 10y agoClojurescript does include a bunch of things you have to use libraries for in JS. Such as immutable data-structures.
- bschwindHN 10y agoYes, I think the language lends itself really well to working with React and writing UI code in general. But I understand that it's hard for a team to migrate to an entirely different language so I get why people use React or Redux or any of those.
- mathw 10y agoAbsolutely, and Elm bakes the React+Redux model into the language itself and makes it all a lot smoother and cleaner to do - but it doesn't play nice with a lot of JS libraries which you could use fairly easily with React/Redux. Always tradeoffs, sadly.
- acgourley 10y agoThis puts a lot of logic in your components. This isn't necessarily bad for small apps, but it's hard to test and it's really bad if you have a react-web + react-native app where you'll be writing platform specific components
- linkmotif 10y agoIt's one of the simplest things ever. Problem is the docs. Could be reduced to a readme. Too much ado about a tiny simple module. Just look at the code. It's nothing. But it also does nothing much. Now Relay...
- Sophistifunk 10y agoAgreed. We're moving things from Redux to Mobx, and I would definitely use it for any new React thing I felt the need to build tomorrow.
- kentor 10y agoRedux is for people who appreciates immutability. A lot of newbies don't appreciate immutability.
- coldtea 10y agoA lot of seasoned developers don't either. Because they've read "No Silver Bullet" and know a specific solution sold as a panacea when they see one.
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]