Skip to content

Commit

Permalink
🐛 fix useResizeObserver initialSize mutation (#504)
Browse files Browse the repository at this point in the history
* fix useResizeObserver initialSize mutation

* Create gold-spiders-invent.md

---------

Co-authored-by: Julien <juliencaron@protonmail.com>
  • Loading branch information
iuriiiurevich and juliencrn authored Feb 22, 2024
1 parent 6d3bca9 commit b88cc01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gold-spiders-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"usehooks-ts": patch
---

fix `useResizeObserver` initialSize mutation (#504 from @iuriiiurevich)
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function useResizeObserver<T extends HTMLElement = HTMLElement>(
const { ref, box = 'content-box' } = options
const [{ width, height }, setSize] = useState<Size>(initialSize)
const isMounted = useIsMounted()
const previousSize = useRef<Size>(initialSize)
const previousSize = useRef<Size>({ ...initialSize })
const onResize = useRef<ResizeHandler | undefined>(undefined)
onResize.current = options?.onResize

Expand Down

0 comments on commit b88cc01

Please sign in to comment.