Search code examples
reactjsreduxflux

Why to mutate Redux state?


I had a job interview question and I was asked:

When would we want to mutate the Redux's store state?

Normally, you return a new instance of the state of the store instead of mutating it. Assume that React JS is out of the picture and we use a different UI library where shouldComponentUpdate() is not in the equation.

I couldn't answer the question and I would like the help from the community in case the same question pops up. Thanks!


Solution

  • It must be a trick question, because the answer is never.

    Please see the Redux FAQ section on immutability for more details.