Open tf opened 5 years ago
Ah, interesting! I haven't come across this yet, but it makes total sense. I appreciate the detailed answer 🙏. It seems worth it to mention this in the README. As for react-measure
V2, it doesn't actually use get-node-dimensions
. I just realized it's listed in dependencies when it shouldn't be 😅.
I noticed this issue when I was using
react-measure
on a piece of DOM that contained a video tag withpreload
attribute set to"auto"
. During an animation,getNodeDimensions
was called while the measured element was alreadydisplay: none
. The measured dimensions were therefore zero, which causes a fallback togetCloneDimensions
. In Firefox 67 the cloned video tag then triggered a separate preload request. In my case this happened quite often and caused hitting theNetwork.http.max-persistent-connections-per-server
limit. This then prevented other videos on the page from loading properly.As a workaround I added an option to prevent the fallback to cloning. The name of the option is quite terrible, but I could not think of anything more descriptive.
I am wondering if this automatic fallback to cloning really makes sense. Maybe instead, there should be an option to opt-in to the fallback. That would of course be a breaking change.
I also saw that the 3.0 pre relases of
react-measure
no longer depend on this library. So this issue might not be a priority? Just wanted to document my findings in case somebody else runs into the problem.