2017-02-16 7 views
0

Reduxアプリケーションでreselect libraryのselectorsを使用しようとしています。TypeScriptでreduxアプリケーションでセレクタを使用するには?

import { createSelector } from 'reselect' 

const postsSelectors = state => state.global.posts.allPostse; 

export const getPosts = createSelector(
    [ postsSelectors ], 
    (posts) => posts 
); 

をし、私はこのように、私のコンポーネントで使用するようにしてください:

私のセレクタファイルが見えます

const mapStateToProps = (state) => ({ 
    posts: getPosts(state), 
}); 

私はこのすべてをコンパイルしようとすると、私はこのエラーを得ました:

enter image description here

私は推測している私は小道具のための型を宣言する方法とその現在は次のようになっています:

interface Props{ 
posts(state: any): any 
loadStories(): void; 
}; 

この問題を解決してください。前もって感謝します。

答えて

1

TypeScriptは、最初の引数の配列を期待していません。あなたのセレクタ関数を次のようにcreateSelectorの引数として渡します。

export const getPosts = createSelector(
    postsSelectors, 
    (posts) => posts 
); 
関連する問題