2016-09-04 7 views
2

私はこのエラーを取得しています:なぜ「次へ」がreduxミドルウェアコードで定義されていないと言われていますか?ミドルウェアの次の方法は廃止予定ですか?

index.js?dadc:6Uncaught TypeError: next is not a function

は廃止ReactJSにミドルウェアが使用する次の方法であり、または私は間違ってそれを使用していますか?

引数なしで applyMiddlewarelogger()の戻り値を渡しているので、働いていない
import { applyMiddleware, combineReducers , createStore } from 'redux'; 

const logger =(store) => (next) => (action) => { 

    console.log('middle-ware called'); 
    next(action); 

} 

const reducer=(state ,action)=>{ 
    if(action.type=='INC'){ 
     console.log('a-----------------',action); 
     return state+action.payload; 
    } 
    else 
     return state; }; 

const store=createStore(reducer ,1 ,applyMiddleware(logger())); 



store.subscribe(()=>{ 
    console.log('store changed',store.getState()) }); 

store.dispatch({type :'INC' ,payload : 10}); store.dispatch({type :'INC' ,payload : 10}); 
+0

についての詳細を読むことができますか? – martriay

答えて

4

これを修正するには、logger()の代わりにloggerapplyMiddleware()の代わりに渡す必要があります。

あなたが `` logger`で `next`の値をconsole.log`場合に発生するもののカスタムミドルウェアhere

+0

ありがとうございます:) –

+0

歓迎です: - P – QoP

関連する問題