【发布时间】:2019-06-26 08:21:21
【问题描述】:
假设我有这个
interface IProps {
text: string
}
class TextComponent extends PureComponent<IProps> {
render() {
return (
<Text>{this.props.text}</Text>
)
}
}
function mapStateToProps(state: ITextComponentReduxStore) {
return {
text: state.text,
}
}
function dispatchAction(dispatch: (x: any) => any) {
return {
}
}
export default connect(mapStateToProps, dispatchAction)(TextComponent)
当我想使用这个组件时,我只是这样做
<TextComponent />
^^^^^^^^^^^^^^^^^ <- Webstorm underlines this
Webstorm (TSLint) 抱怨
TS2741: Property 'text' is missing in type '{}' but required in type 'Readonly<Pick<IProps, "text">>'.
我怎样才能防止这种情况发生?
props 是 Redux store 的一部分
【问题讨论】:
标签: react-native react-redux webstorm tslint