Skip to content

Commit

Permalink
compose: Add types to useResizeObserver (#32111)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarayourfriend authored May 25, 2021
1 parent 59a3b77 commit f10179b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
11 changes: 7 additions & 4 deletions packages/compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,13 @@ _Returns_
Hook which allows to listen the resize event of any target element when it changes sizes.
_Note: `useResizeObserver` will report `null` until after first render_

Simply a re-export of `react-resize-aware` so refer to its documentation <https://github.com/FezVrasta/react-resize-aware>
for more details.

_Related_

- <https://github.com/FezVrasta/react-resize-aware>

_Usage_

```js
Expand All @@ -421,10 +428,6 @@ const App = () => {
};
```

_Returns_

- `Array`: An array of {Element} `resizeListener` and {?Object} `sizes` with properties `width` and `height`

<a name="useThrottle" href="#useThrottle">#</a> **useThrottle**

Throttles a function with Lodash's `throttle`. A new throttled function will
Expand Down
5 changes: 4 additions & 1 deletion packages/compose/src/hooks/use-resize-observer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import useResizeAware from 'react-resize-aware';
* Hook which allows to listen the resize event of any target element when it changes sizes.
* _Note: `useResizeObserver` will report `null` until after first render_
*
* @return {Array} An array of {Element} `resizeListener` and {?Object} `sizes` with properties `width` and `height`
* Simply a re-export of `react-resize-aware` so refer to its documentation <https://github.com/FezVrasta/react-resize-aware>
* for more details.
*
* @see https://github.com/FezVrasta/react-resize-aware
*
* @example
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useState, useCallback } from '@wordpress/element';
/**
* Hook which allows to listen the resize event of any target element when it changes sizes.
*
* @return {Array} An array of {Element} `resizeListener` and {?Object} `sizes` with properties `width` and `height`
* @return {[JSX.Element, { width: number, height: number } | null]} An array of {Element} `resizeListener` and {?Object} `sizes` with properties `width` and `height`
*
* @example
*
Expand Down
2 changes: 2 additions & 0 deletions packages/compose/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
"src/hooks/use-constrained-tabbing/**/*",
"src/hooks/use-debounce/**/*",
"src/hooks/use-instance-id/**/*",
"src/hooks/use-isomorphic-layout-effect/**/*",
"src/hooks/use-focus-return/**/*",
"src/hooks/use-previous/**/*",
"src/hooks/use-media-query/**/*",
"src/hooks/use-reduced-motion/**/*",
"src/hooks/use-merge-refs/**/*",
"src/hooks/use-resize-observer/**/*",
"src/utils/**/*"
]
}

0 comments on commit f10179b

Please sign in to comment.