diff --git a/changelogs/upcoming/7518.md b/changelogs/upcoming/7518.md deleted file mode 100644 index 07585f3da793..000000000000 --- a/changelogs/upcoming/7518.md +++ /dev/null @@ -1,4 +0,0 @@ -**Bug fixes** - -- Fixed `useResizeObserver` hook to return the initial dimension correctly - ([#7518](https://github.com/elastic/eui/pull/7518)). diff --git a/src-docs/src/views/resize_observer/resize_observer_hook.js b/src-docs/src/views/resize_observer/resize_observer_hook.js index 270b0fac636f..4fa43f11938a 100644 --- a/src-docs/src/views/resize_observer/resize_observer_hook.js +++ b/src-docs/src/views/resize_observer/resize_observer_hook.js @@ -1,4 +1,4 @@ -import React, { useRef, useState } from 'react'; +import React, { useState } from 'react'; import { EuiButton, @@ -24,8 +24,8 @@ export const ResizeObserverHookExample = () => { setItems((items) => [...items, `Item ${items.length + 1}`]); }; - const resizeRef = useRef(); - const dimensions = useResizeObserver(resizeRef.current); + const [resizeRef, setResizeRef] = useState(); + const dimensions = useResizeObserver(resizeRef); return (