H
H
heIIfire2018-02-23 00:00:03
redux
heIIfire, 2018-02-23 00:00:03

Why does the state need to be immutable?

Why the state can only be replaced with a new one and not change it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2018-02-23
@undefined_title

if the reducer changes the state and returns it, then subscribers (components) will not be notified about its change, since redux will think that the state has not changed, because the comparison of the previous and next state is not deep, but only the reference is compared, and in general it is recommended in FP use pure functions and work with everything immutably, this makes it easier to debug and simplifies testing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question