添加redux-thunk会导致remote-redux-devtools失效

时间:2017-03-27 06:33:39

标签: reactjs react-native redux react-redux redux-devtools

当我将redux-thunk添加到我的react本机项目时,我的redux远程devtools不会保持任何状态。状态在远程devtools窗口中显示为undefined。以前(devtools工作):

const store = createStore(
  reducer,
  initialState,
  devToolsEnhancer()
)

更改为(devtools停止工作):

const store = createStore(
  reducer,
  initialState,
  applyMiddleware(thunk),
  devToolsEnhancer()
)

我在createStore做错了订单吗?

更新:我认为需要composeEnhancers。尝试了一些不同的但不起作用:

const store = createStore(
  reducer,
  initialState,
  composeEnhancers(applyMiddleware(thunk)),
  devToolsEnhancer()
)

1 个答案:

答案 0 :(得分:-1)

取自remote-redux-devtools github页面:

而不是

import devToolsEnhancer from 'remote-redux-devtools'
const store = createStore(
  reducer,
  initialState,
  devToolsEnhancer()
)

做的:

import { composeWithDevTools } from 'remote-redux-devtools'
const store = createStore(
  reducer,
  initialState,
  composeWithDevTools(applyMiddleware(thunk))
)