antonioru / beautiful-react-hooks

🔥 A collection of beautiful and (hopefully) useful React hooks to speed-up your components and hooks development 🔥

Home Page:https://antonioru.github.io/beautiful-react-hooks/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

useResizeObserver reports incorrect return type

genepaul opened this issue · comments

Describe the bug
useResizeObserver reports that it returns DOMRectValues. However, the state variable DOMRect is initialized to undefined, which will cause the first render with that hook to return undefined. Indeed, the documentation seems to demonstrate that you should always check for the existence of the DOMRect before doing anything with it. I can definitely open a PR to fix this.

To Reproduce
Steps to reproduce the behavior:

  1. Use the results of useResizeObserver in a TypeScript environment, and realize that it is potentially undefined.

Expected behavior
I would like it to report DOMRectValues | undefined.

Desktop (please complete the following information):

  • OS: all
  • Browser all
  • Version latest

Smartphone (please complete the following information):

  • Device: all
  • OS: all
  • Browser all
  • Version latest

Additional context

commented

Hey @genepaul thanks for pointing this out and thanks for your PR, I'll review it soon