当我将redux-thunk添加到我的react本机项目中时,我的redux远程devtools没有任何状态。状态在远程开发工具窗口中显示未定义。以前(开发工具工作(:
const store = createStore(
reducer,
initialState,
devToolsEnhancer()
)
更改为(开发工具停止工作(:
const store = createStore(
reducer,
initialState,
applyMiddleware(thunk),
devToolsEnhancer()
)
我在createStore
中做错了顺序吗?
更新:我认为需要composeEnhancers
。尝试了几种变体,但不起作用:
const store = createStore(
reducer,
initialState,
composeEnhancers(applyMiddleware(thunk)),
devToolsEnhancer()
)
取
自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))
)