Step 1: Install redux-saga. npm install redux-saga.Step 2: Import the libraries. /src/configure-store. … Step 3: Create a root saga. /src/configure-store. … Step 4: Create instance of saga middleware. … Step 5: Apply the saga middleware to redux. … Step 6: Run the saga.
What is difference between redux and redux saga?
Saga works like a separate thread or a background process that is solely responsible for making your side effects or API calls unlike redux-thunk, which uses callbacks which may lead to situations like ‘callback hell’ in some cases. However, with the async/await system, this problem can be minimized in redux-thunk.
What is the advantage of redux saga?
Testability. It’s very easy to test sagas as call() returns a pure object. Testing thunks normally requires you to include a mockStore inside your test. redux-saga comes with lots of useful helper functions about tasks.