François Richard François Richard -3 years ago 118
React JSX Question

Do I need a saga for local store changes ? (redux-saga)

It may be a naive/not smart question:

I want to keep track of a global state in my app. The user for example choose some options for the app and I want those options to be accessible from any component in my app.
So I trigger some "setOptions" action and have a reducer for it. This action dosn't need any server call it's internal to the app.

My question is, do it needs to have it's own saga ? In my opinion it's not really needed here but maybe it's good practice to do it this way to better keep tracks of thing ?

What do you think the better option is ?

thanks

Answer Source

That's not the use case for redux-sagas. Redux-saga is for async operations. If your intent is to keep a property global, your redux store already has you covered in all ramifications of it.

You already have your reducer setup. So once you dispatch an action in that case the store is updated with the new state by your reducer. I think that's all you need since you're not making a server call whatsoever.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download