Search code examples
javascriptreactjsreduxredux-sagasaga

Does Redux Saga select return mutable state?


Does Redux Saga select return a mutable or immutable state?

See https://github.com/redux-saga/redux-saga


Solution

  • The select operator just uses the Redux store's getState() method internally. So, the return value from the selector function is probably going to correspond to the contents of the store state tree.

    Redux itself does not actually stop you from mutating your state. It wants you to handle state immutably, but the base library does not enforce that in any way.

    As a result, if your store state tree is composed of plain JS objects, then yes, the return value from select is almost definitely going to be mutable. If your store state tree use made up of something like Immutable.js Maps and Lists, then the return value from select will probably be immutable.