Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Do I have to use redux saga to fetch from an API if I don't need to store the data in the redux store?

I’m already familiar with how Redux saga works, my question is more around best-practices. I have an application in which I have actions which are dispatched, then intercepted by saga where it runs an API call, and then the saga dispatches another action, usually storing the data to the redux store.

My question is, what if I just need to call an API from my front-end but don’t need to store the data in the redux store? Do I just call my API from the front-end directly (e.g. with axios/fetch API?) or do I have to use saga to fetch it?

In the second case where I use saga, how do I pass the data up from saga to the component (without adding the response data to the redux store)?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you don’t need the data in the store (component state is enough) then just querying the data directly from the component (via react-query or some other data fetching layer) is "better" in the sense that you don’t have to "globalize" that data in your application state (don’t need actions/reducers/selectors)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading