TypeError: Cannot read property 'parentElement' of null
See original GitHub issueDo you want to request a feature or report a bug?
Report a bug
What is the current behavior?
I’m trying to use the ResponsiveContainer to wrap a component but in tests (Jest), i’m getting the following error:
TypeError: Cannot read property 'parentElement' of null
Here’s a gist with the test and the component:
https://gist.github.com/Carlows/e276e740a2a739d3a73cb1053d386134
The same error happened to me when trying to render the LineChart component in a test.
Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?
Version 0.22.0, I’m not aware of this working or not working in other versions, but I didn’t found anything related to this anywhere.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:9
Top Results From Across the Web
Javascript Cannot read property 'parentElement' of null
Using Chome's debug mode (F12), set a breakpoint on the line oldImage.parentElement. · It could be that the script is running before the...
Read more >waitForElementToBeRemoved: TypeError: Cannot read ...
Problem description: react-modal is removing the parentElement of the queried element. The queried element is given to waitForElementToBeRemoved ...
Read more >TypeError: Cannot read property 'parentNode' of Null in JS
The "Cannot read property 'parentNode' of null" error occurs when you access the parentNode property on a null value. To solve the error,...
Read more >TypeError: Cannot read property 'parentElement' of null
Fresh project generated by create-react-app@4: @testing-library/dom version: 5.11.4; Testing Framework and version: <!-- are you using jest, ...
Read more >Uncaught TypeError: Cannot read property of null - iDiallo
All this means is that you are trying to access a property of an object that is undefined. These usually happens when we...
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 FreeTop 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
Top GitHub Comments
The issue comes from the ResponsiveContainer component and is caused by the use of refs. As a workaround you can mock refs in snapshot testing
The following test should work
Hey @xile611 this issue is fixed in
react-resize-detector
(see https://github.com/maslianok/react-resize-detector/pull/40) But this package is still depends on an old version https://github.com/recharts/recharts/blob/13997461cd7f82302704c14a20fb123b2433338c/package.json#L64 Don’t you consider to update the version of this dependency to the latest?