【发布时间】:2019-10-31 02:29:43
【问题描述】:
我在 reactjs 应用中有一个类组件,我希望它使用路由器和翻译。
interface CommonHeaderProps extends RouteComponentProps<any> {
}
class CommonHeader extends React.Component<CommonHeaderProps> {
render() {
return (
<div>
</div>
);
}
}
const mapStateToProps = (state: RootState) => ({
})
const mapDispatchToProps = {};
export default withRouter(connect(
mapStateToProps,
mapDispatchToProps
)(CommonHeader));
我希望这个组件是
withRouter()(CommonHeader)
和
withTranslation()(CommonHeader)
但是这样做不起作用
export default withTranslation()(withRouter(connect(
mapStateToProps,
mapDispatchToProps
)(CommonHeader)));
我试过了
const Component = connect(
mapStateToProps,
mapDispatchToProps
)(CommonHeader)
export default compose<CommonHeader>(
withTranslation,
withRouter,
)(Component)
但是当我尝试调用组件时出现以下错误:
JSX 元素类型“CommonHeader”没有任何构造或调用 签名
【问题讨论】:
标签: reactjs