Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performing background tasks in react components with Redux

I would like to know if there is any best option to do a time consuming network request as a background task in react component.

For example, I have to load a component where it is accessible to the user but in background i have to hit some high intensive network request for future loading and results of same has to be updated in redux store(Using react-redux). It would be really helpful if someone share some ideas on this. Thanks in advance.

like image 228
AndroidKid Avatar asked Mar 20 '26 18:03

AndroidKid


1 Answers

One of the ways is to create action creators that will perform any task, regardless of sync or async and update the store accordingly. Redux-thunk is the middleware that can help you to achieve this.

https://github.com/gaearon/redux-thunk

like image 125
Shivansh Singh Avatar answered Mar 22 '26 06:03

Shivansh Singh