question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Invalid attempt to destructure non-iterable instance

See original GitHub issue

HI… im new in this project…but when run the code like belove

export function showMessage() {
  return {
    type: SHOW_MESSAGE,
    promise: (client) => client.get('/posts')
  };
}

i get this error: TypeError: Invalid attempt to destructure non-iterable instance can anyone Helllllp Me??? tnx

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
chatzipancommented, Aug 14, 2016

Hi @majidkarimizadeh. I believe you should follow @jahmaiosullivan’s advice and make your type an Array. In your case try something like the following, instead of changing the middleware.

export function showMessage() {
  return {
    types: [SHOW_MESSAGE, SHOW_MESSAGE_SUCCESS, SHOW_MESSAGE_FAIL],
    promise: (client) => client.get('/posts')
  };
}

Try giving all your fetch actions the same types pattern.

0reactions
davidfurlongcommented, Dec 14, 2016

i change some part of clientMiddlware and solve it…

// const [REQUEST, SUCCESS, FAILURE] = types; const REQUEST = ‘REQUEST’; const SUCCESS = ‘SUCCESS’; const FAILURE = ‘FAILURE’; i think i have some problem with my babel and somthing like that 😃

It looks like babel is trying to destructure types in const [REQUEST, SUCCESS, FAILURE] = types; and is failing - check that your types in your action creators are defined & have >=3 elements

type:[REQUEST, SUCCESS, FAILURE],

This is a typo, it should be types: [REQUEST, SUCCESS,FAILURE]

Read more comments on GitHub >

github_iconTop Results From Across the Web

React JS Error: Invalid attempt to destructure non-iterable ...
Invalid attempt to destructure non-iterable instance says the instance you are trying to iterate is not iterable.
Read more >
How I Fixed: TypeError: Invalid attempt to destructure non ...
This morning I hit upon a really annoying problem whilst trying to write a basic test for a React component.
Read more >
Invalid attempt to destructure non-iterable instance. #65 - GitHub
I am trying the picker on the expo app, I get this error. I tried the sample Single Date picker code. why is...
Read more >
Invalid attempt to destructure non-iterable instance-Reactjs
Coding example for the question Uncaught TypeError: Invalid attempt to destructure non-iterable instance-Reactjs.
Read more >
invalid attempt to destructure non-iterable instance
The error Invalid attempt to destructure non-iterable instance occurs because of a logic/coding error. The following javascript is used to illustrate the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found