【Redux】store

store is 何

redux.js.org

A store holds the whole state tree of your application.

state全般を保存する場所
・reducerにより生成された新たなstate
・変更が加わっていないstate

storeを作る

createStoreメソッド
: storeを作る

storeに全てのreducerを含ませる

storeは全てのreducerを含んでいる
combineReducersメソッド :
全てのreducerをまとめることができる

Providerでstoreを使用可能にする

</Provider>でラップ(wrap)されたコンポーネント
storeが使用可能になる

import { Provider } from 'react-redux'

import { ComponentA } from './path/to/ComponentA'

import createStore from './path/to/store'

<Provider store={store}>
  <Component A/>
</Provider>

// component A はstoreを使用可能になる

connect

anect.hatenablog.com

storeとcomponentをBindingする

connect(
  mapStateToProps,
  mapDispatchToProps,
  mergeProps
)(Component);

connectの各引数がこれまたムズい‥