3 ms·
Having used Redux for some elaborate stuff (in particular, a web app that used a couple of KB of info in Redux to generate an extremely dynamic UI, with diff-st
by crooked-v 6y ago
Having used Redux for some elaborate stuff (in particular, a web app that used a couple of KB of info in Redux to generate an extremely dynamic UI, with diff-style data changes via Websockets inserted in realtime), honestly, the biggest problem I've seen with Redux use is just... people using it for things when they shouldn't.
This is most glaring for the whole "do a GET and store it in Redux" thing, where if there's no actual data mutation or derived data or anything else that actually requires or makes use of a global scope, you should just be using a memoized API call function (or a library that abstracts away the common use cases of one, like SWR).
- Udik 6y agoSo what would be your guesstimate on the percentage of redux uses in the wild that are unnecessary and just introduce complexity or boilerplate instead of providing a benefit?
- acemarke 6y agoFWIW, my current estimates are that roughly 50% of all React apps use Redux. I'm gonna go out on a limb and guess that maybe 1/3 of those Redux-using apps probably aren't really benefiting from Redux (things like using it _just_ to avoid prop-drilling when you could just use Context, writing reducers that are nothing more than `return action.payload` with no real logic, etc). We've always had an entry in our FAQ section that gives some advice for when it might make sense to put a particular piece of state into Redux vs keeping it in component state. As I rewrite the Redux docs piece by piece, I'm trying to add some additional clarification and emphasis on when you should actually consider using Redux overall.
- deckard1 6y ago> people using it for things when they shouldn't I know people that advocate putting everything in redux. They are quite serious about this. Then you end up with reselect everywhere and the whole goddamn universe is memoized. No one seems to know how React renders (or re-renders), so memoize everything! Yes! That's the ticket. The overuse of Redux and the React hook brain damage stems from the tide finally turning against OOP. Haskell did a number on the OOP paradigm. So everyone is afraid of encapsulated state and localized logic. Then you end up with React hooks. Instead of making React's object API better, they choose to make functions worse. So everyone is pretending they are doing functional programming when in reality they are just using functions that are bastardized with this weird flavor of dynamic scoping and all the subtleties of that. But I digress. Today, there are a thousand different ways to do web development wrong and practically no way to do it right. Starting with misconfiguring webpack and working up the stack. It's a true complexity quagmire. But surely there is a SaaS or open source toolkit (with adjacent commercial services!) coming soon to help guide us out of the fog. Just kidding. This hell of ours is by design.
- crooked-v 6y ago> Instead of making React's object API better, they choose to make functions worse. I'd be really curious to see how you'd make the object API reusably composable, given that that's one of the basic reasons for hooks existing as they do.
- discreteevent 6y agoAn over emphasis on re-use is what ruined a lot of oop systems also. Maximise reuse, minimise use. It's a trade-off.
- city41 6y agoI pretty much totally agree. FWIW, I do think there might be some good things on the horizon. Rome has a lot of potential, as do Remix and Svelte. We'll get past this :)