2017-04-11 16 views
1

は、次の関数を考えてみましょう:React Redux接続コンポーネントのフローリターンタイプは何ですか?

import type { ConnectedComponent } from "react-redux"; 

function createContainer(ComponentToConnect): ConnectedComponent<*, *, *, *> { 
    // ... define mapStateToProps, mapDispatchToProps 
    return connect(mapStateToProps, mapDispatchToProps)(ComponentToConnect) 
} 

これは私に次のフローエラーを与える:

class type: type application of polymorphic type: class type: ConnectedComponent This type is incompatible with the expected return type of ConnectedComponent

このようなReduxの連結成分を返す関数に指定する正しい戻り値の型は何ですか?

答えて

1

実際にクラスConnectedComponent<*, *, *, *>が返されているように見えるのに対し、createContainerはConnectedComponent<*, *, *, *>というインスタンスを返しています。 createContainerの返品タイプClass<ConnectedComponent<*, *, *, *>をお試しください。

関連する問題