Skip to content

Instantly share code, notes, and snippets.

@zapkub
Created November 15, 2018 11:37
Show Gist options
  • Save zapkub/17e5c9825347156e8aa3ff54556da48f to your computer and use it in GitHub Desktop.
Save zapkub/17e5c9825347156e8aa3ff54556da48f to your computer and use it in GitHub Desktop.
// 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