Skip to content


Browse files Browse the repository at this point in the history
Added logic to wire-up the 'Add new item...' button to prompt the use…
…r for the new item when clicked, and to update the <ListWidget> 'state' field 'items' to a new array of items including the just-added item, to cause it to be re-rendered by React with that new item.
  • Loading branch information
maratbn committed Aug 5, 2018
1 parent 83e7ace commit 74cf9b3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion webpack_in/entry.jsx
Expand Up @@ -98,7 +98,23 @@ class ListWidget extends React.Component {
<ButtonWidget caption="Add new item..." />
<ButtonWidget caption="Add new item..."
onClick={() => {
const strItemNew = prompt("Please enter new item to add:",
"Item "
+ (this.state.items.length + 1));
if (strItemNew === null) {

items: [
<ButtonWidget caption="Edit item..." />
<ButtonWidget caption="Remove item..." />
Expand Down

0 comments on commit 74cf9b3

Please sign in to comment.