Skip to content

Instantly share code, notes, and snippets.

@benkissi
Created April 15, 2019 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benkissi/caf955a1dd9cc649da0954aac31ceb43 to your computer and use it in GitHub Desktop.
Save benkissi/caf955a1dd9cc649da0954aac31ceb43 to your computer and use it in GitHub Desktop.
Context blog
addTodo(todo) {
const { todos } = this.state;
const newTodo = {
id: Math.floor(Math.random() * (1000 - 1)) + 1,
todo: todo,
createdAt: Date.now(),
completed: false
};
this.setState({
todos: todos.concat(newTodo)
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment