mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 13:48:51 +08:00
24 lines
575 B
TypeScript
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>
|
|
);
|
|
}
|
|
}
|