Skip to content

Commit 19d01ff

Browse files
committed
Modified <ListWidget> state schema to add new field 'total_added' to keep track of the total number of times a new item has been added. This new field is intended to be used to give each item a unique lifetime ID to be used as the React key in the items listing, as well as to find the item to update its future checked status.
1 parent bebcb07 commit 19d01ff

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

webpack_in/entry.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class ListWidget extends React.Component {
8383
"Item 1",
8484
"Item 2",
8585
"Item 3"
86-
]
86+
],
87+
total_added: 3
8788
};
8889
}
8990

@@ -112,7 +113,8 @@ class ListWidget extends React.Component {
112113
items: [
113114
...this.state.items,
114115
strItemNew
115-
]
116+
],
117+
total_added: this.state.total_added + 1
116118
});
117119
}}/>
118120
<ButtonWidget caption="Edit item..." />

0 commit comments

Comments
 (0)