C
C
cester2017-11-01 17:53:41
JavaScript
cester, 2017-11-01 17:53:41

Middleware is not a function, why such an error?

Good afternoon! Please tell me what could be the problem?
I'm trying to make an asynchronous request, according to I want to use redux-thunk applyMiddleware It gives an
error - middleware is not a function .
It is not clear how the full picture should look like, what should be returned from actions!?
To use applyMiddleware(thunk) should I just add it to createStore?
I don't quite understand how it works.
I would be very grateful for any help!
store.js code

const mapStore = createStore(
  rootReducer,
  compose(applyMiddleware(thunk), window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__())
);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Alexandrovich, 2017-11-01
@cester

import thunk from "redux-thunk";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question