Want to Do Dispatch. Then(. ..)

Want to Do Dispatch. Then(. ..)

I use redux, react-redux, react-router, and react-router-redux, and redux-thunk.

import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import { browserHistory } from 'react-router'
import { routerMiddleware } from 'react-router-redux'
import  thunkMiddleware from 'redux-thunk'
...    
const reduxRouterMiddleware = routerMiddleware( browserHistory )

const store = createStore(
    mainReducer,
    applyMiddleware(reduxRouterMiddleware, thunkMiddleware)
)

I was hoping as a result to be able to do thenable dispatch

dispatch(...).then()

but I get the message that then is not a function of dispatch.

How can I accomplish this?

4

1 Answer

the answer: it depends on what is returned by dispatch; if a promise is returned, then it will be thenable.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.