TypeError: Invalid attempt to destructure non-iterable instance
20,930
Solution 1
I faced with the same issue and looking I found that was a typo. you should use types instead of type i.e:
export function showMessage() {
return {
types: [MESSAGE_FETCH, MESSAGE_FETCH_SUCCESS, MESSAGE_FETCH_FAIL],
promise: (client) => client.get('/post')
}
}
Bear in mind that the array of 'types' will dispatch those action(success or fail) when the promise will be resolved.
Solution 2
if you are having this issue while working with es6 version of For Of loop, just check wheather you used .entries() on the array or not.
Example:
for( const [item. index] of arr.entries() ) {
console.log(index);
}
Author by
Majid Karimizadeh
I'm a Software Engineer with 7+ years of experience. For most of my career, I've been focused on the PHP (Laravel) and Javascript (React) development.
Updated on July 03, 2020Comments
-
Majid Karimizadeh almost 4 years
I'm new in this project and I'm trying to use the
react-redux-universal-hot-example
API, but using my code:export function showMessage() { return { type: SHOW_MESSAGE, promise: (client) => client.get('/posts') }; }
I get this error in my browser:
TypeError: Invalid attempt to destructure non-iterable instance
Can anyone help?