Files
eh-downloader/components/GlobalContext.tsx
2023-05-26 08:39:21 +08:00

24 lines
575 B
TypeScript

import { Component, ComponentChild, createContext } from "preact";
export const GlobalCtx = createContext<State | null>(null);
type State = {
stylesheets: Set<string>;
};
type Props = { children: ComponentChild };
export default class GlobalContext extends Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { stylesheets: new Set() };
}
render() {
return (
<GlobalCtx.Provider value={this.state}>
{this.props.children}
</GlobalCtx.Provider>
);
}
}