2021-01-05 19:49:33 +00:00
|
|
|
import React, { useContext, useState } from "react";
|
2020-09-17 11:37:30 +00:00
|
|
|
|
2021-01-05 19:49:33 +00:00
|
|
|
type RealmContextType = {
|
|
|
|
realm: string;
|
|
|
|
setRealm: (realm: string) => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const RealmContext = React.createContext<RealmContextType>({
|
2020-10-02 06:47:32 +00:00
|
|
|
realm: "",
|
2021-01-05 19:49:33 +00:00
|
|
|
setRealm: () => {},
|
2020-09-17 11:37:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
type RealmContextProviderProps = { children: React.ReactNode };
|
|
|
|
|
|
|
|
export const RealmContextProvider = ({
|
|
|
|
children,
|
|
|
|
}: RealmContextProviderProps) => {
|
2021-01-05 19:49:33 +00:00
|
|
|
const [realm, setRealm] = useState("");
|
2020-09-17 11:37:30 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<RealmContext.Provider value={{ realm, setRealm }}>
|
|
|
|
{children}
|
|
|
|
</RealmContext.Provider>
|
|
|
|
);
|
|
|
|
};
|
2021-01-05 19:49:33 +00:00
|
|
|
|
|
|
|
export const useRealm = () => useContext(RealmContext);
|