2016-12-23 3 views
0

I am trying to call the reducer from the component and want to render that in component , but when I am trying to store the reducer in the createStore() method of redux above error is coming. My Code is like this:-不明なエラー:エンハンサーは、あなたがCREATESTORE機能の代わりに、1に2つの減速に渡している機能

import { applyMiddleware, compose, createStore } from 'redux' 
import thunk from 'redux-thunk' 
import { browserHistory } from 'react-router' 
import makeRootReducer from './reducers' 
import { updateLocation } from './location' 
import allReducers from './reducers'; 

export default (initialState = {}) => { 
    // ====================================================== 
    // Middleware Configuration 
    // ====================================================== 
    const middleware = [thunk] 

    // ====================================================== 
    // Store Enhancers 
    // ====================================================== 
    const enhancers = [] 

    let composeEnhancers = compose 

    if (__DEV__) { 
    const composeWithDevToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ 
    if (typeof composeWithDevToolsExtension === 'function') { 
     composeEnhancers = composeWithDevToolsExtension 
    } 
    } 

    // ====================================================== 
    // Store Instantiation and HMR Setup 
    // ====================================================== 
    const store = createStore(
    allReducers, 
    makeRootReducer(), 
    initialState, 

    composeEnhancers(
     applyMiddleware(...middleware), 
     ...enhancers 
    ) 
) 

I am getting error :Uncaught Error: Expected the enhancer to be a function

答えて

1

されると予想。

createStoreの3番目の引数は常にエンハンサー関数ですので、 'initiaeState'変数は、これをcreateStoreのthid引数として渡すのでエンハンサー関数であると考えます。

CREATESTOREは、次の引数を受け取ることを期待:

  1. reducer (Function): A reducing function that returns the next state tree, given the current state tree and an action to handle.
  2. [preloadedState] (any): The initial state. You may optionally specify it to hydrate the state from the server in universal apps, or to restore a previously serialized user session. If you produced reducer with combineReducers, this must be a plain object with the same shape as the keys passed to it. Otherwise, you are free to pass anything that your reducer can understand.

  3. [enhancer] (Function): The store enhancer. You may optionally specify it to enhance the store with third-party capabilities such as middleware, time travel, persistence, etc. The only store enhancer that ships with Redux is applyMiddleware().

アプリのルート減速機が1つの減速にすべてのあなたのレデューサーを組み合わせる必要があります覚えておいてください。 Redux docs

First and foremost, it's important to understand that your entire application really only has one single reducer function

から

関連する問題