https://qiita.com/uryyyyyyy/items/d8bae6a7fca1c4732696
上記「ReduxでのMiddleware不要論」を参考にtypescriptで
ActionDispactherを作っています。
ただしActionDispactherにもrootStateを渡してよりなんでもできる感じにしてしまっています。
以下のような感じです
typescript
1export interface Props extends React.Props<{}> { 2 login: Login; 3 actions: ActionDispatcher; 4} 5 6export default class Header extends React.Component<Props, {}> { 7// 省略
typescript
1export default connect( 2 (state: reducers.State) => ({ state }), 3 (dispatch) => ({ dispatch }), 4 ({ state }, { dispatch }, ownProps) => ({ login: state.login, actions: new ActionDispatcher(dispatch, state) }) 5)(Header); 6
上記書き方で特に問題なくtypeScript2.5系では使えていたのですが
typescript2.6.0にしたところ以下のようなエラーが出るようになりました
[ts] Argument of type 'typeof Header' is not assignable to parameter of type 'ComponentType<Props>'. Type 'typeof Header' is not assignable to type 'StatelessComponent<Props>'. Type 'typeof Header' provides no match for the signature '(props: Props & { children?: ReactNode; }, context?: any): ReactElement<any> | null'.
connectの書き方が良くないせいなのかとも思うのですがちょっとわからなくて悩んでいます。
ご教授いただけないでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。