Created
November 17, 2019 09:35
-
-
Save webmasterdevlin/c6da16130af7a9d09e45c343985b0e5b to your computer and use it in GitHub Desktop.
Observables
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*/ | |
heroes: [], | |
hero: { | |
id: "", | |
firstName: "", | |
lastName: "", | |
house: "", | |
knownAs: "" | |
}, | |
isLoading: false, | |
error: "" | |
})); | |
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