How Does Redux Saga Work

How Does Redux Saga Work

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.

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.