mirror of https://github.com/morpheus65535/bazarr
32 lines
583 B
TypeScript
32 lines
583 B
TypeScript
import {
|
|
createContext,
|
|
FunctionComponent,
|
|
PropsWithChildren,
|
|
useContext,
|
|
} from "react";
|
|
|
|
const SettingsContext = createContext<Settings | null>(null);
|
|
|
|
export function useSettings() {
|
|
const context = useContext(SettingsContext);
|
|
|
|
return context;
|
|
}
|
|
|
|
type SettingsProviderProps = {
|
|
value: Settings | null;
|
|
};
|
|
|
|
type Props = PropsWithChildren<SettingsProviderProps>;
|
|
|
|
export const SettingsProvider: FunctionComponent<Props> = ({
|
|
value,
|
|
children,
|
|
}) => {
|
|
return (
|
|
<SettingsContext.Provider value={value}>
|
|
{children}
|
|
</SettingsContext.Provider>
|
|
);
|
|
};
|