我正在尝试扩展我现有的布局以基本上覆盖方法 renderHeader() 但流程不喜欢它:
module ./Layout [1] 不是多态类型。
我该如何解决?
这是我试图扩展的一个类(它不是抽象的):
Layout.js
//@flow
import * as React from 'react';
import Header from '../header/Header';
import '../../css/settings/utilities.css';
export type LayoutProps = {
children: React.Node,
};
class Layout extends React.PureComponent<LayoutProps> {
renderHeader() {
return <Header />;
}
render() {
return (
<React.Fragment>
<h1 className="u-hd">My Wee Loyalty Prime</h1>
{this.renderHeader()}
<main className="main">{this.props.children}</main>
</React.Fragment>
);
}
}
export default Layout;
这是我应该扩展的类: LayoutRegistration.js
//@flow
import * as React from 'react';
import Header from '../header/Header';
import * as Layout from './Layout';
import '../../css/settings/utilities.css';
export default class LayoutRegistration extends Layout {
renderHeader() {
return <Header showSubnav={false} />;
}
}