Created
November 17, 2019 09:32
-
-
Save webmasterdevlin/25e5202cc11d69ee01df9dc31b3b267b to your computer and use it in GitHub Desktop.
Provider
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
import React, { createContext } from "react"; | |
import { useLocalStore } from "mobx-react-lite"; | |
import { | |
deleteHero, | |
getHeroById, | |
getHeroes, | |
postHero, | |
putHero | |
} from "./hero-service"; | |
export const HeroProvider = ({ children }) => { | |
const store = useLocalStore(() => ({ | |
/*observables here*/ | |
/*actions here*/ | |
/*computed values i.e. derived state here*/ | |
})); | |
return <heroContext.Provider value={store}>{children}</heroContext.Provider>; | |
}; | |
export const heroContext = createContext(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment