Created
June 1, 2020 09:33
-
-
Save Odonno/59c273006d5c4d5c502b615fe234b5a4 to your computer and use it in GitHub Desktop.
State management comparison - mobx - StoreContext
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
const StoreContext = createContext<TodoList>({} as TodoList); | |
type StoreContextProviderProps = { | |
children?: ReactNode; | |
}; | |
export const StoreProvider = ({ children }: StoreContextProviderProps) => { | |
const todoList = new TodoList(); | |
return ( | |
<StoreContext.Provider value={todoList}> | |
{children} | |
</StoreContext.Provider> | |
); | |
}; | |
export const useStore = () => useContext(StoreContext); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment