Skip to content
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

Basic usage is not working #92

Closed
andyperlitch opened this issue May 3, 2022 · 3 comments
Closed

Basic usage is not working #92

andyperlitch opened this issue May 3, 2022 · 3 comments
Labels
bug Something isn't working react-18 released

Comments

@andyperlitch
Copy link

Hello there! I'm trying to get the absolute minimum usage example working, and am running into an issue. I have tried on linux and mac, on firefox and chrome, and cannot get it to work.

Here is a code sandbox reproducing it:
https://codesandbox.io/s/exciting-surf-uos1hs?file=/src/App.js

You will see that the onResize function is being called with the new size, however, the width variable returned by useResizeObserver is not getting updated.

@ZeeCoder ZeeCoder added react-18 bug Something isn't working labels May 3, 2022
@ZeeCoder
Copy link
Owner

ZeeCoder commented May 3, 2022

Hi!
Thank you very much for the reproduction.

There seems to be 2 issues here:

  • Since you're passing in "onResize", you're actually opting out of the width/height responses. This is because the callback allows you to opt out of rendering altogether.
  • The width/height responses doesn't seem to work with react 18 anyway, and are stuck at the default "1x1" for me. 🤷‍♂️

I'm working on an update to make the hook compatible, so this'll be a good test case.

@andyperlitch
Copy link
Author

I'm so glad my repro helped you out! Good to know about the onResize function.

github-actions bot pushed a commit that referenced this issue May 15, 2022
# [9.0.0](v8.0.0...v9.0.0) (2022-05-15)

### Bug Fixes

* Added some fixes for React 18. ([852d976](852d976)), closes [#90](#90) [#91](#91) [#92](#92)

### BREAKING CHANGES

* The lib now takes "Element", not only "HTMLElement", to
be consistent with ResizeObserver.
@github-actions
Copy link

🎉 This issue has been resolved in version 9.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working react-18 released
Projects
None yet
Development

No branches or pull requests

2 participants