Skip to content

Instantly share code, notes, and snippets.

@rcdexta
Last active November 26, 2018 08:43
Show Gist options
  • Save rcdexta/41dc83412c0f9b6a1a74f5dbc374331f to your computer and use it in GitHub Desktop.
Save rcdexta/41dc83412c0f9b6a1a74f5dbc374331f to your computer and use it in GitHub Desktop.
import React from 'react'
class App extends React.Component {
state = {
items: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6"]
};
addItem = newItem => {
this.setState({ items: [...this.state.items, newItem] });
};
render() {
return (
<div>
<ItemList items={this.state.items} />
<NewItem onAdd={this.addItem} />
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment