【发布时间】:2018-05-18 21:08:09
【问题描述】:
我的组件有一些自己的道具
class Props {
wizard: WizardConfig;
}
我想访问路由器历史记录,所以我也传递了路由器道具
type PropsType = Props & RouteComponentProps<{}>;
class Wizard extends React.Component<PropsType> {}
问题是在组件的使用中
<Wizard wizard={someWizar} />
我收到 RouteComponentProps 道具未通过的错误,例如:
Property 'match' is missing in type '{ wizard: WizardConfig; }'
我尝试过:
export default withRouter(Wizard);
但它没有帮助。
【问题讨论】:
-
如果您希望该类型具有 Route... 的一个或多个属性...但不是全部,您可以尝试声明为 Partial - Partial
我>
标签: reactjs typescript react-router