Created
January 9, 2019 08:34
-
-
Save mohanramphp/0f37c309a468cd8ad6fb8b9e6d42ee85 to your computer and use it in GitHub Desktop.
Todos component using React hook
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, { useReducer } from 'react'; | |
import { TodoForm } from './TodoForm'; | |
import { TodoList } from './TodoList'; | |
import { TodoReducer, TodosDispatch } from './TodoReducer'; | |
export const Todos = ({ todos }) => { | |
const [state, dispatch] = useReducer(TodoReducer, todos); | |
return ( | |
<div className="todos-container"> | |
<TodosDispatch.Provider value={dispatch}> | |
<TodoForm></TodoForm> | |
<TodoList todos={state}></TodoList> | |
</TodosDispatch.Provider> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment