63
rated 0 times
[
66]
[
3]
/ answers: 1 / hits: 15463
/ 7 Years ago, tue, september 26, 2017, 12:00:00
I'm writing a HOC component for next.js pages, and this HOC needs to accept a component with a specific getInitialProps
static function.
I can't get figure out the right typing for this with 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} />;
}
}
}
I get this error:
5: const original: Function = Component.getInitialProps;
^ property `getInitialProps`. Property not found in
5: const original: Function = Component.getInitialProps;
^ statics of React$Component
More From » reactjs