Skip to content

Instantly share code, notes, and snippets.

@zapkub
Created November 15, 2018 11:30
Show Gist options
  • Save zapkub/04c1b2fb2d6e89b836ca482f89b00500 to your computer and use it in GitHub Desktop.
Save zapkub/04c1b2fb2d6e89b836ca482f89b00500 to your computer and use it in GitHub Desktop.
// TodoInput.jsx
const TodoInput = () => {
const [textInput, setTextInput] = React.useState("");
function onTextChange(e) {
setTextInput(e.target.value);
}
return (
<input className="new-todo" value={textInput} onChange={onTextChange} />
);
};
const TodoList = () => (
<TodoStoreConsumer>
{store => (
<ul className="todo-list">
{store.todos.map(todo => (
<li>
<TodoItem {...todo} />
</li>
))}
</ul>
)}
</TodoStoreConsumer>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment