我正在为next编写一个HOC组件。js页面,这个HOC需要接受具有特定
getInitialProps
我无法使用flow找到正确的键入方式:
const wrapComponent = (Component: React.ComponentType<*>) => {
const original: Function = Component.getInitialProps;
return class extends React.Component<*> {
static async getInitialProps(ctx) {
const props = await original(ctx);
return {
...props,
custom: 'a',
};
}
render() {
return <Component {...this.props} />;
}
}
}
我发现这个错误:
5: const original: Function = Component.getInitialProps;
^ property `getInitialProps`. Property not found in
5: const original: Function = Component.getInitialProps;
^ statics of React$Component
Demo