3 ms·
Interesting to hear someone who clearly tried to use it seriously. That said I do agree with the first comment on the article itself, he is using his "useFetch"
by iraldir 7y ago
Interesting to hear someone who clearly tried to use it seriously. That said I do agree with the first comment on the article itself, he is using his "useFetch" in a very far fetched (haha) way. A hooks should not be called as a callback to an event, you should "trigger an action" (whether redux, a callback from a higher component etc.) that update a state which in turns trigger the hook. I understand this can be length / annoyingly administrative but that is the cost of the react architecture, with the payoff being to better understand the flow of the application.
- concerned_user 7y agoI use redux and react-saga for more complex flows, sagas translate into generators and make async code flows look almost like synchronous code which is nice.
- machiaweliczny 7y agoSagas are nice to read but hard to test. IMO simpler async functions are enough. Is there any benefit to sagas that I don't see?
- acemarke 7y agoSagas are a great power tool... and 95% of Redux apps don't actually need them. Using them just for basic data fetching is overkill. Sagas are most useful when you need to do complex async logic, like cancellation, debouncing, and decoupled "background-thread"-like computations. Thunks are sufficient for most use cases, but the main thing they can't do is respond to dispatched actions. For more info, see the Redux FAQ entry on choosing an async middleware: https://redux.js.org/faq/actions#what-async-middleware-should-i-use-how-do-you-decide-between-thunks-sagas-observables-or-something-else https://redux.js.org/faq/actions#what-async-middleware-shoul...