@@ -50,7 +50,7 @@ Adding Interactivity
5050 :link: dangers-of-mutability/index
5151 :link-type: doc
5252
53- Under construction 🚧
53+ See the pitfalls of working with mutable data types and how to avoid them.
5454
5555
5656Section 1: Responding to Events
@@ -187,11 +187,24 @@ To accomplish this, instead of passing the next state value directly (e.g.
187187Section 5: Dangers of Mutability
188188--------------------------------
189189
190+ While state can hold any type of value, you should be careful to avoid directly
191+ modifying objects that you declare as state with IDOM. In other words, you must not
192+ :ref: `"mutate" <What is a Mutation >` values which are held as state. Rather, to change
193+ these values you should use new ones or create copies.
194+
195+ This is because IDOM does not understand that when a value is mutated, it may have
196+ changed. As a result, mutating values will not trigger re-renders. Thus, you must be
197+ careful to avoid mutation whenever you want IDOM to re-render a component. For example,
198+ instead of mutating dictionaries to update their items you should instead create a
199+ copy that contains the desired changes:
200+
201+ .. idom :: dangers-of-mutability/_examples/dict_update
202+
190203.. card ::
191204 :link: dangers-of-mutability/index
192205 :link-type: doc
193206
194207 :octicon: `book ` Read More
195208 ^^^^^^^^^^^^^^^^^^^^^^^^^
196209
197- .. .
210+ See the pitfalls of working with mutable data types and how to avoid them .
0 commit comments