Created
November 15, 2018 11:37
-
-
Save zapkub/17e5c9825347156e8aa3ff54556da48f to your computer and use it in GitHub Desktop.
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
// store/index.jsx | |
const TodoStoreProvider = ({ children }) => { | |
const [todos, setTodos] = useState([ | |
{ | |
title: "Touch myself." | |
}, | |
{ | |
title: "Sleep peacefully" | |
} | |
]); | |
const store = { | |
todos, | |
submitTodo: (title) => setTodos(todos.concat({ title })) | |
}; | |
return ( | |
<TodoStoreContext.Provider value={store}> | |
{children} | |
</TodoStoreContext.Provider> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment