首页 > 解决方案 > 使用redux(mobx)注入的打字稿类型检查反应组件的问题

问题描述

类型检查不适用于由商店注入的导出组件,导出道具接口也不起作用。

interface IProps{
    //...types here
}
export class TaskList extends React.Component<IProps, IState> {
    //...class content
}

export default compose(withNavigation, inject("store"), observer)(TaskList);

然后在另一个组件中,当我尝试调用时

<TaskList 
    //...props here 
/>

这些道具没有经过类型检查(它们甚至没有出现在 VSCode 的 IntelliSense 上),因为它们位于正常导出的其他组件中。

标签: reactjstypescriptreact-redux

解决方案


推荐阅读