Skip to content

Instantly share code, notes, and snippets.

@greaveselliott
Last active June 22, 2019 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greaveselliott/a1e260fc6f9006b39a9b5eb9380c85f3 to your computer and use it in GitHub Desktop.
Save greaveselliott/a1e260fc6f9006b39a9b5eb9380c85f3 to your computer and use it in GitHub Desktop.
import React, { createContext, useReducer } from "react";
import reducer from "./reducer";
export const Store = createContext();
const initialState = {
list: []
};
export function StoreProvider({ children }) {
const [state, dispatch] = useReducer(reducer, initialState);
const value = { state, dispatch };
return <Store.Provider value={value}>{children}</Store.Provider>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment