keycloak-scim/src/context/realm-context/RealmContext.tsx
2020-10-06 10:25:38 +02:00

22 lines
602 B
TypeScript

import React, { useState, useContext } from "react";
import { WhoAmIContext } from "../../context/whoami/WhoAmI";
export const RealmContext = React.createContext({
realm: "",
setRealm: (realm: string) => {},
});
type RealmContextProviderProps = { children: React.ReactNode };
export const RealmContextProvider = ({
children,
}: RealmContextProviderProps) => {
const homeRealm = useContext(WhoAmIContext).getHomeRealm();
const [realm, setRealm] = useState(homeRealm);
return (
<RealmContext.Provider value={{ realm, setRealm }}>
{children}
</RealmContext.Provider>
);
};