mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
30 lines
708 B
TypeScript
30 lines
708 B
TypeScript
import { Component, ComponentChild, createContext } from "preact";
|
|
import { StateUpdater } from "preact/hooks";
|
|
|
|
type State = {
|
|
set_value: StateUpdater<Record<string, unknown>>;
|
|
};
|
|
|
|
type Props = {
|
|
children: ComponentChild;
|
|
set_value: StateUpdater<Record<string, unknown>>;
|
|
};
|
|
|
|
export const BCtx = createContext<State | null>(null);
|
|
|
|
export default class BContext extends Component<Props, State> {
|
|
constructor(props: Props) {
|
|
super(props);
|
|
this.state = {
|
|
set_value: props.set_value,
|
|
};
|
|
}
|
|
render() {
|
|
return (
|
|
<BCtx.Provider value={this.state}>
|
|
{this.props.children}
|
|
</BCtx.Provider>
|
|
);
|
|
}
|
|
}
|