Last active
June 28, 2019 00:36
-
-
Save ifndefdeadmau5/054a11c062a25b81bbbe94f5c5661ef9 to your computer and use it in GitHub Desktop.
Imperative.js
This file contains hidden or 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'; | |
export default () => { | |
const [input, setInput] = useState(''); | |
let todos = []; | |
return ( | |
<div> | |
<input | |
type="text" | |
value={input} | |
onChange={event => setInput(event.target.value)} | |
/> | |
<button | |
onClick={() => { | |
todos = [...todos, input]; | |
const listElement = document.getElementById('list'); | |
const newTodo = document.createTextNode(input); | |
listElement.appendChild(newTodo) | |
}} | |
> | |
확인 | |
</button> | |
<List id="list"> | |
{todos} | |
</List> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment