13 lines
408 B
TypeScript
13 lines
408 B
TypeScript
import { FunctionComponent } from "preact";
|
|
import { useEffect } from "preact/hooks";
|
|
|
|
export const withTitle = <P,>(title: string, WrappedComponent: FunctionComponent<P>): FunctionComponent<P> => {
|
|
const ComponentWithTitle: FunctionComponent<P> = (props) => {
|
|
useEffect(() => {
|
|
document.title = title;
|
|
}, []);
|
|
return <WrappedComponent {...props} />;
|
|
};
|
|
return ComponentWithTitle;
|
|
};
|