-
-
Save amandeepmittal/79460168f2b85c73423fce31d9632e0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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