refact: extract location to provider/hook

This commit is contained in:
Jean-Philippe Sirois
2019-11-08 17:04:09 -08:00
parent ab43fee166
commit 3b3a68698f
4 changed files with 60 additions and 8 deletions
+12
View File
@@ -0,0 +1,12 @@
import { useContext } from "react"
import { ILocationContextInterface, LocationContext } from "../LocationProvider"
export default function useLocation(): ILocationContextInterface {
const locationContext = useContext(LocationContext)
if (!locationContext) {
throw Error("Need context")
}
return locationContext
}