@@ -4,21 +4,58 @@ Managing State
44.. toctree ::
55 :hidden:
66
7- keeping-components-pure
8- logical-flow-of-state
9- structuring-your-state
7+ structuring-your-state/index
108 shared-component-state/index
11- when-to-reset-state
12- writing-tests
9+ when-and-how-to-reset-state/index
1310
11+ .. dropdown :: :octicon:`bookmark-fill;2em` What You'll Learn
12+ :color: info
13+ :animate: fade-in
14+ :open:
15+
16+ .. grid :: 1 2 2 2
17+
18+ .. grid-item-card :: :octicon:`code-square` Structuring Your State
19+ :link: structuring-your-state/index
20+ :link-type: doc
21+
22+ Make it easy to reason about your application by organizing its state.
23+
24+ .. grid-item-card :: :octicon:`link` Shared Component State
25+ :link: shared-component-state/index
26+ :link-type: doc
27+
28+ Allow components to vary vary together, by lifting state into common
29+ parents.
30+
31+ .. grid-item-card :: :octicon:`light-bulb` When and How to Reset State
32+ :link: when-and-how-to-reset-state/index
33+ :link-type: doc
34+
35+ Control if and how state is preserved by understanding it's relationship to
36+ the "UI tree".
1437
1538
1639Section 4: Shared Component State
1740---------------------------------
1841
19- Sometimes you want the state of two components to always change together. To do it, you
20- need to be able to share state between those two components, to share state between
21- componets move state to the nearest parent. In React world this is known as "lifting
22- state up" and it is a very common thing to do. Let's look at 2 examples, also from
23- `React <https://beta.reactjs.org/learn/sharing-state-between-components >`__,
24- but translated to IDOM.
42+ Sometimes, you want the state of two components to always change together. To do it,
43+ remove state from both of them, move it to their closest common parent, and then pass it
44+ down to them via props. This is known as “lifting state up”, and it’s one of the most
45+ common things you will do writing code with IDOM.
46+
47+ In the example below the search input and the list of elements below share the same
48+ state, the state represents the food name. Note how the component ``Table `` gets called
49+ at each change of state. The component is observing the state and reacting to state
50+ changes automatically, just like it would do in React.
51+
52+ .. idom :: shared-component-state/_examples/synced_inputs
53+
54+ .. card ::
55+ :link: shared-component-state/index
56+ :link-type: doc
57+
58+ :octicon: `book ` Read More
59+ ^^^^^^^^^^^^^^^^^^^^^^^^^
60+
61+ Allow components to vary vary together, by lifting state into common parents.
0 commit comments