2016-06-13 29 views

回答

0

還原啓動器默認安裝了react-router-reduxredux-thunk

由於您沒有提供任何代碼,因此我不確定是否進行了API調用,但是如果您可以將商店注入到您的API包裝中,也許您可​​以通過您的redux商店調度路由器操作。

假設你正在使用某種形式的API包裝的和的thunk,你可以做這樣的事情:

import { push } from 'react-router-redux'; 

function myThunkFunction() { 
    return dispatch => axios.get(...).catch((error) => { 
    /** insert logic to determine 500 error **/ 
    if (500error) { 
     dispatch(push('http://example.com/error/500')); 
    } 
    }); 
} 
相關問題