TypeError: Cannot destructure property 'error' of 'results[(results.length - 1)]' as it is undefined. [Suspense]
See original GitHub issuereact-hooks-testing-library
version: 5.0.2react
version: 17.0.1react-dom
version (if applicable): 17.0.1react-test-renderer
version (if applicable):17.0.1node
version:14.13.1npm
(oryarn
) 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:
- Created 3 years ago
- Comments:64 (64 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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! 😃
rerender() is what i can use to reset error boundary?