Closed emiloberg closed 8 years ago
Hmmm, I am struggling to think why this is. Could you please link me to the package that is consuming react-sizeme
?
Or a sample project that I could use for debugging... :)
I've just done a patch release which includes a fix for event listener race condition issues with unmounted components. It may help your case, please try and let me know.
https://github.com/ctrlplusb/react-sizeme/releases/tag/v2.0.1
Seeing a similar issue as well.
@tonyxiao any chance you could throw up a sample project for me? I'm more than happy to debug the issue.
@tonyxiao I see you have forked and attempted to lazy load the resizer. Did it have any effect on the issue?
@ctrlplusb yes that fixed the issue for me. I haven't figured out "why" it fixes the issue other than it does :P
It crashes even at import time due to importing an external package element-size-monitor
(or something like that, forgot the exact name)
WIll see if I can get a super clean example later.
@tonyxiao awesome. :)
Thanks for looking into this, I think I understand what is going on now. I had a look at the element-resizer source and there is definitely some DOM interaction that goes on just by instantiating it, so your fix is perfect. Looks like @emiloberg was on the right track too. Thanks for this gents.
Don't worry about a sample project. I think we can move forward with the fix. Are you happy to send a PR?
There was a patch release available for element-resize-detector
so I have updated react-sizeme
and have done a release.
@tonyxiao heads up. :)
Sweet, thank you @ctrlplusb for being so responsive!
No probs. :) Thanks for your help! :)
Just to be clear my recent change doesn't include your changes. Are you happy to proceed with a PR? I don't mind completing it either if you have your hands full.
Yep created. https://github.com/ctrlplusb/react-sizeme/pull/8
Thanks @tonyxiao!
As I work in an enterprise portal environment I have to deliver my React bundles in a quite unorthodox way.
I attach the Webpack build bundle to the window object. The
output
property of my Webpack config looks a little bit like this:I then pick up the component from the window object (e.g.
window.reactComponents.myStuff123
) and render the React component as such:However, as I add a package, which includes react-resizeme, to the window object I guess that it's immediately trying to set up some event listeners or such, because I get this error:
Is there any way of postponing the execution until it's actually rendered?
Loading example
A full example of the HTML and loading mechanisms looks like this: