From c58086ed33b6abe0411edfd6e8ba372cfd6f66a2 Mon Sep 17 00:00:00 2001 From: Logan Belew <118302540+loganbelew2@users.noreply.github.com> Date: Fri, 19 Apr 2024 09:27:48 -0500 Subject: [PATCH] =?UTF-8?q?The=20old=20broken=20link=20to=20the=20state=20?= =?UTF-8?q?tree=20diagram=20has=20been=20replaced=20with=20=E2=80=A6=20(#4?= =?UTF-8?q?700)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/faq/ReactRedux.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/faq/ReactRedux.md b/docs/faq/ReactRedux.md index fbfa02a283..6a18e03a25 100644 --- a/docs/faq/ReactRedux.md +++ b/docs/faq/ReactRedux.md @@ -52,7 +52,7 @@ Overall, React-Redux encourages good React architecture, and implements complex Accidentally mutating or modifying your state directly is by far the most common reason why components do not re-render after an action has been dispatched. Redux expects that your reducers will update their state “immutably”, which effectively means always making copies of your data, and applying your changes to the copies. If you return the same object from a reducer, Redux assumes that nothing has been changed, even if you made changes to its contents. Similarly, React Redux tries to improve performance by doing shallow equality reference checks on incoming props in `shouldComponentUpdate`, and if all references are the same, `shouldComponentUpdate` returns `false` to skip actually updating your original component. -It's important to remember that whenever you update a nested value, you must also return new copies of anything above it in your state tree. If you have `state.a.b.c.d`, and you want to make an update to `d`, you would also need to return new copies of `c`, `b`, `a`, and `state`. This [state tree mutation diagram](http://arqex.com/wp-content/uploads/2015/02/trees.png) demonstrates how a change deep in a tree requires changes all the way up. +It's important to remember that whenever you update a nested value, you must also return new copies of anything above it in your state tree. If you have `state.a.b.c.d`, and you want to make an update to `d`, you would also need to return new copies of `c`, `b`, `a`, and `state`. This [state tree mutation diagram](https://miro.medium.com/v2/resize:fit:1400/1*87dJ5EB3ydD7_AbhKb4UOQ.png) demonstrates how a change deep in a tree requires changes all the way up. Note that “updating data immutably” does _not_ mean that you must use [Immer](https://github.com/immerjs/immer), although that is certainly an option. You can do immutable updates to plain JS objects and arrays using several different approaches: