Skip to content

Instantly share code, notes, and snippets.

@ifndefdeadmau5
Created June 28, 2019 00:38
Show Gist options
  • Save ifndefdeadmau5/00e486d0b2d5cee9a38eac45129ccd8a to your computer and use it in GitHub Desktop.
Save ifndefdeadmau5/00e486d0b2d5cee9a38eac45129ccd8a to your computer and use it in GitHub Desktop.
Declarative.js
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