Description
Provide a general summary of the issue here
If useResizeObserver
is used on current browsers, onResize
is fired on first use.
For older browsers that don't support ResizeObserver
, it is fired after the first resize of the browser window.
🤔 Expected Behavior?
onResize
is triggered on first render
😯 Current Behavior
onResize
is not triggered on first use as in supported browsers
💁 Possible Solution
We should call onResize
in useEffect for an unsupported browser condition.
react-spectrum/packages/@react-aria/utils/src/useResizeObserver.ts
Lines 21 to 26 in f6a664b
🔦 Context
The original ResizeObserver
is called on the observe
method.
For the mock implementation with the resize
event, we do not have this behaviour. The first onResize
must be called manually.
🖥️ Steps to Reproduce
Codesandbox with "simulated" old browser by setting window.ResizeObserver = undefined
https://codesandbox.io/p/sandbox/useresizeobserver-not-triggered-on-init-hx3mkm
or use the hook in older browsers like Firefox 68.0
Version
1.1.1
What browsers are you seeing the problem on?
Firefox
If other, please specify.
No response
What operating system are you using?
Mac
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response