Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: Invalid attempt to destructure non-iterable instance

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?

like image 738
Majid Karimizadeh Avatar asked Aug 08 '16 15:08

Majid Karimizadeh


Video Answer


1 Answers

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);
}
like image 131
Partha Roy Avatar answered Nov 01 '22 10:11

Partha Roy