Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. addTodo(todo) {
  2. const { todos } = this.state;
  3. const newTodo = {
  4. id: Math.floor(Math.random() * (1000 - 1)) + 1,
  5. todo: todo,
  6. createdAt: Date.now(),
  7. completed: false
  8. };
  9. this.setState({
  10. todos: todos.concat(newTodo)
  11. });
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement