Created
June 28, 2019 00:38
-
-
Save ifndefdeadmau5/00e486d0b2d5cee9a38eac45129ccd8a to your computer and use it in GitHub Desktop.
Declarative.js
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'; | |
import List from './List'; | |
import Item from './Item'; | |
export default () => { | |
const [input, setInput] = useState(''); | |
const [todos, setTodos] = useState([]); | |
return ( | |
<div> | |
<input | |
type="text" | |
value={input} | |
onChange={event => setInput(event.target.value)} | |
/> | |
<button | |
onClick={() => { | |
setTodos([...todos, input]); | |
}} | |
> | |
확인 | |
</button> | |
<List> | |
{todos.map(todo => ( | |
<Item>{todo}</Item> | |
))} | |
</List> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment