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: Cannot destructure property 'error' of 'results[(results.length - 1)]' as it is undefined. [Suspense]

See original GitHub issue
  • react-hooks-testing-library version: 5.0.2
  • react version: 17.0.1
  • react-dom version (if applicable): 17.0.1
  • react-test-renderer version (if applicable):17.0.1
  • node version:14.13.1
  • npm (or yarn) version:1.22.5

Relevant code or config:

expect(result.error).toBe(null);

What you did:

Directly after the renderHooks() line with a function that throws a Promise

What happened:

Reproduction:

result.error just after a hook that suspends (don’t await the resolution of suspense).

result.current was fixed in https://github.com/testing-library/react-hooks-testing-library/commit/dc21e5947a54adfaf348bfeaeab56d37a4e7e2bb but result.error was not.

Problem description:

Suspense is the most important use of this library

Suggested solution:

Do the thing in https://github.com/testing-library/react-hooks-testing-library/commit/dc21e5947a54adfaf348bfeaeab56d37a4e7e2bb but apply to all members

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:64 (64 by maintainers)

github_iconTop GitHub Comments

1reaction
ntuckercommented, Jan 31, 2021

Oh wow, I didn’t realize it wasn’t actually a promise. I kinda expected typescript to complain about awaiting something that isn’t a promise. Well, thanks for all your help - upgrade complete! 😃

1reaction
ntuckercommented, Jan 31, 2021

rerender() is what i can use to reset error boundary?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot destructure property as it is undefined - reactjs
The error is clear. You're not sending any props to the App component, so { steps } is undefined, and you can't destructure...
Read more >
Next.js error: Cannot destructure property? : r/learnjavascript
I am following a tutorial and I cannot figure out why Next keeps throwing this error: TypeError: Cannot destructure property 'loginUser' of ...
Read more >
TypeError: Cannot destructure property '…' of 'Object ...
(The common issue which results in this error is about wrong exports/imports which is discussed a lot on StackOverflow. However, this error was...
Read more >
TypeError: Cannot destructure property 'product' of ' ...
I'm getting the warning ( React Hook useEffect has a missing dependency: 'dispatch' ) which I doubt it is the cause of the...
Read more >
useContext
My component doesn't see the value from my provider; I am always getting undefined from my context although the default value is different ......
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