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.

Invalid attempt to destructure non-iterable instance.

See original GitHub issue

I am trying the picker on the expo app, I get this error. I tried the sample Single Date picker code. why is the destructing array but it expects an object.

Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.
const [date, setDate] = (React.useState < Date) | (undefined > undefined);
const [open, setOpen] = React.useState(false);

Changing it to this solves the problem but throws an errow setOpen is not a fucntion when I dismissed the modal

const {date, setDate} = (React.useState < Date) | (undefined > undefined);
  const {open, setOpen} = React.useState(false);

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
RichardLindhoutcommented, Apr 1, 2021
const [date, setDate] = React.useState<Date | undefined>(undefined)

I think you’re pasting typescript code in your javascript code. Javascript version looks like

const [date, setDate] = React.useState(undefined)
1reaction
Kadwekacommented, Jul 15, 2022

change it from const [userInfo] = useContext(AuthContext) to const {userInfo}= useContext(AuthContext)

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-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 >
Invalid attempt to destructure non-iterable instance.
[React] Uncaught TypeError: Invalid attempt to destructure non-iterable instance. ... e.target은 객체이지만 배열의 형태로 구조분해할당 시도했기 때문에 에러가 ...
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