Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dandelionadia/d38845138e67164e99a7f803abc5f208 to your computer and use it in GitHub Desktop.
Save dandelionadia/d38845138e67164e99a7f803abc5f208 to your computer and use it in GitHub Desktop.
state = {
persons: [
{ id: 'asfa1', name: 'Max', age: 28 },
{ id: 'vasdf1', name: 'Manu', age: 29 },
{ id: 'asdf11', name: 'Stephanie', age: 26 }
],
otherState: 'some other value',
showPersons: false,
showCockpit: true,
changeCounter: 0
};
_____________________
nameChangedHandler = (event, id) => {
...
this.setState((prevState, props) => {
return {
persons: persons,
changeCounter: prevState.changeCounter + 1
};
});
};
_________________
<Persons
persons={this.state.persons}
clicked={this.deletePersonHandler}
changed={this.nameChangedHandler}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment