18 ms·
I just dove back into react after a while in vue and deep in some backend systems. I love the new ergonomics (hooks, useEffect, redux tools) but I definitely h
by code_runner 5y ago
I just dove back into react after a while in vue and deep in some backend systems.
I love the new ergonomics (hooks, useEffect, redux tools) but I definitely hit the exact issue OP mentions almost immediately.
I don’t feel that the solution react provides is too out there, but agree it could be better. The react ecosystem still makes it worth the one or two “could be betters” for me.
- bayesian_horse 5y agoYou may need to think about how you implement asynchronous side effects. Declaring them with useEffect quickly gets annoying. Look for things like thunks or saga. Or when not using Redux, at least think about using async functions. In general I want to keep async logic out of my components as much as possible. I also don't want the component rendering to drive the async logic.
- code_runner 5y agohave you had any success using the useReducer hook totally outside of redux? I feel like its bulky for certain operations but I still haven't found that "perfect" use-case for it yet that makes it click for me
- bayesian_horse 5y agoSo far not. But I can imagine things. For example imagine a Game of life component with two actions, "evolve" and "set_cell". Basically any time when it is awkward to have exactly one mutation function (setter) for a piece of state. Other examples are a minesweeper game. Basically any time it is too awkward to compose different mutations on top of a single setter. The other big benefit is that you can test the reducer without the component. And compared to redux, it still has a smaller footprint. So it doesn't have the dependencies, you don't need to setup a store etc.