私はreact-reduxのconnect
関数に渡されるコンポーネントを作成しようとしています。 コンポーネントは次のとおりです。タイプ・スクリプトのReact-Redux接続の問題
interface ITestProps {
id: number
}
class TestComponent extends React.Component<ITestProps, {}> {
render() {
return (<div>
{this.props.name}
</div>)
}
}
mapStateToProps(state) {}
mapDispatchToProps(dispatch) {}
let ConnectedComponent = connect(
mapStateToProps,
mapDispatchToProps
)(TestComponent)
上記のコードは、私がid
小道具なしでそう
<ConnectedComponent></ConnectedComponent>
すなわちようConnectedComponent
をレンダリングする場合は見つける動作しているようです。 ConnectedComponent
は単にTestComponent
という接続形式であり、TestComponent
の形式はITestProps
という形式のプロンプトを持つ必要があるため、エラーは発生しません。 これは動作するかどうか、または何か間違っているかどうかです。
ない活字に精通上記
を追加しましたが、なぜあなたは別の名前(ConnectedComponent)が必要ですか?あなたは 'export default connect(mapStateToProps、mapDispatchToProps)(TestComponent);'と ' TestComponent>'のような何かを行うことはできませんか? –
それは私がやっていることです..私はちょうどそれが理解しやすいだろうと思った –
こんにちは、あなたはどのような定義の種類は、あなたのredux反応のために使用していますか? – AlexG