maslianok / react-resize-detector

A Cross-Browser, Event-based, Element Resize Detection for React
http://maslianok.github.io/react-resize-detector/
MIT License
1.25k stars 91 forks source link

The hook pattern is causing crashes on iOS #117

Closed Dwyte closed 3 years ago

Dwyte commented 3 years ago

When I use the hook pattern for resize detection with ref it causes crashes on iOS 12 on any browser. (Firefox, Brave (Chromium-Based), Safari) on newer version of iOS and iphones it seems fine. I had the crash on iphone 6. Sorry If I couldn't give any more details as I cannot really access the debug logs of the browser since I don't have a mac computer.

Replacing it with the withResizeDetector pattern works fine tho.

maslianok commented 3 years ago

v6 doesn't include ResizeObserver polyfill by default.

Looking at the browser support I think this may be a problem https://caniuse.com/resizeobserver

Please try to import

import ResizeObserver from 'react-resize-detector/withPolyfill';

(the other parts remain the same)

the only difference with the default import is size: the default module is 3kb and the one with polyfill takes about 6kb

Dwyte commented 3 years ago

@maslianok I am getting cannot find module error. There's no /withPolyfill directory. I am using v6alpha.0.

maslianok commented 3 years ago

@Dwyte please upgrade to the latest RC version "6.0.1-rc.5"

maslianok commented 3 years ago

As we found in this issue https://github.com/maslianok/react-resize-detector/issues/123 the path should be react-resize-detector/build/withPolyfill