Use custom middleware for async actions - Uncaught Error: Actions must be plain objects

321 Views Asked by At

I am getting following error on redux store for async calls, I read few of the stack-overflow solutions but it doesn't help much :

Error:

Uncaught Error: Actions must be plain objects. Use custom middleware for async actions.
    at dispatch (createStore.js:105)
    at Object.getDeviceRedistributeIsisToBGPStatus (bindActionCreators.js:14)

Sharing the function being called from component file:

> export const getDeviceRedistributeIsisToBGPStatus =  (primaryDevice,
    > peerDevice) => {   return async dispatch => {
    >     const primaryConst = (primaryDevice !== '') ? await getRedistributeIsisToBGPStatus(primaryDevice) : false
    >     const peerConst = (peerDevice !== '') ? await getRedistributeIsisToBGPStatus(peerDevice): false
    >     const res = (primaryConst !== false || peerConst !== false ) ? false: true
    >     if(res){
    >       dispatch({ type: actionTypes.UPDATE_FORM_FIELD_VALUE, name:'redistributeIsisToBgp',value:false});
    >     }
    >     dispatch({
    >       type: actionTypes.DISABLE_REDISTRIBUTE_ISIS_TO_BGP_CHECKBOX, redistributeIsisToBGPStatus: res
    >     })   } }

Can somebody please let me know where I am going wrong.

0

There are 0 best solutions below