我需要使用 redux-thunk 中间件,但是当我将其作为参数传递给
applyMiddleware
函数时,它显示以下错误:
return middleware(middlewareAPI);
^
TypeError: middleware is not a function
这是我使用 thunk 的代码片段:
import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
import reducer from "./reducers.js";
const store = createStore(reducer, applyMiddleware(thunk))
导致此错误的问题是什么?
使用以下代码代替 thunk
const thunkMiddleware = require('redux-thunk').thunk