1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ReactでcombineReducersを使った時にReduxからデータが流れてこなくてハマったのでメモ

1
Last updated at Posted at 2020-03-09

個人的メモ

タイトルの通りReduxからデータがどうにもこうにも流れてこなくてウンウン唸って調べ回った結果、単にルールを知らなかっただけだったのでメモ。

combineReducersを使った時にはmapStateProps内でPropsと接続する際にreducerも指定しましょう

以下の様に指定しないとデータが一向に流れてこない。

reducer/index.js
import { combineReducers } from 'redux';
import xxxReducer from './xxxReducer';
import yyyReducer from './yyyReducer';

export default combineReducers({
  xxx: xxxReducer,
  yyy: yyyReducer
});
container/xxxContainer.js
const mapStateToProps = (state) => ({
  data: state.xxx.data,
  error: state.xxx.error
});

知っていればどうってことない事ですが、データが流れてこない時はエラーも出ないしDevツール使ってもデータに問題はないしでかなり時間を使ってしまったので、同じ事をしない様にメモ。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?