Skip to content

Commit

Permalink
Modified <ListWidget> state schema to add new field 'total_added' to …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
maratbn committed Aug 5, 2018
1 parent bebcb07 commit 19d01ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions webpack_in/entry.jsx
Expand Up @@ -83,7 +83,8 @@ class ListWidget extends React.Component {
"Item 1",
"Item 2",
"Item 3"
]
],
total_added: 3
};
}

Expand Down Expand Up @@ -112,7 +113,8 @@ class ListWidget extends React.Component {
items: [
...this.state.items,
strItemNew
]
],
total_added: this.state.total_added + 1
});
}}/>
<ButtonWidget caption="Edit item..." />
Expand Down

0 comments on commit 19d01ff

Please sign in to comment.