-
-
Notifications
You must be signed in to change notification settings - Fork 137
DOM element provided is null or undefined #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for bringing this up @lavor Your first solution seems reasonable. AFAICT the whole promise chain after
Seem plausible? Either way, this isn't a problem that's come up in our own usage of this package so it's not a high priority for Plotly folks to fix, but if you'd like to make a PR this we'd be more than happy to review and incorporate it! |
Thanks @alexcjohnson, yes your solution is also correctly working in my environment. |
Hi guys, I am hitting the same error message when running Storyshots (Jest snapshots for Storybook). I don't really get the proposed solution, is there a palliative I can use within React? |
Hi, I am still getting this error in some circumstances.
[email protected]
[email protected]
I reported this error in the closed issue #52 two months ago. But I did not get any reaction, so I am opening a new issue.
I tried to debug my situation and come to finding that library is not checking if a component is mounted in promise handlers in
updatePlotly
function.Short story
Hence, whenever the component mounts and in next moment it unmounts (before all promises in
updatePlotly
resolves), thesyncWindowResize
will callPlotly.Plots.resize
withnull
(this.el
) as an argument.What happened in my situation in details (I've put some checkpoints in comments in bellow snippet):
getRef
sets ref correctlycomponentDidMount
updatePlotly
- updatePlotly: checkpoint 1updatePlotly
- updatePlotly: checkpoint 2componentWillUnmount
getRef
unmounting sets ref tonull
(see https://reactjs.org/docs/refs-and-the-dom.html#callback-refs)updatePlotly
- updatePlotly: checkpoint 3syncWindowResize
calls Plotly.Plots.resize with argumentthis.el
, which was set tonull
(step 6) and that results inError while plotting: Error: DOM element provided is null or undefined
.Possible solution
Do not call things in promise
then
handler when unmounting:Alternative solution
Do not use
this.unmountig
at all and implement solution with cancelable promises:https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html
The text was updated successfully, but these errors were encountered: