Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created February 18, 2019 12:57
Show Gist options
  • Save amandeepmittal/79460168f2b85c73423fce31d9632e0e to your computer and use it in GitHub Desktop.
Save amandeepmittal/79460168f2b85c73423fce31d9632e0e to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
// ...
export default function App() {
const [value, setValue] = useState('');
const [todos, setTodos] = useState([]);
addTodo = () => {
if (value.length > 0) {
setTodos([...todos, { text: value, key: Date.now(), checked: false }]);
setValue('');
}
};
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment