I get this error with the below code
TypeError: dispatch(...).then is not a function
(anonymous function)
src/actions.js:35
32 | // };
33 |
34 | export const updateStateData = (stateData, stateVariable) => (
dispatch => {
> 35 | return dispatch({
36 | type : 'stateUpdate',
37 | payload : {
38 | stateVariable,
export const updateStateData = (stateData, stateVariable) => (dispatch => {
return dispatch({
type : 'stateUpdate',
payload : {
stateVariable,
stateData
}
})
.then((returnedValue) => {
console.log(returnedValue);
})
});
Yet the below function, also with a chained .then() works. It seems the same to me. Anyone know what the difference is?
export const testThunk = () => ((dispatch) => {
const fakeFetch = () => new Promise((resolve, reject) => (
setTimeout(() => resolve('into the 1st promise data local, and then into the payload value of the action'), 2000)
));
return fakeFetch()
.then((resolvedValue) => {
dispatch({
type: 'thunkTest',
payload: resolvedValue });
return '1st promise return';
})
.then((returnedValue => {
console.log('getstate call', store.getState());
console.log(returnedValue);
}))
});