Skip to content

Commit c52c390

Browse files
committed
Document useFrameSize
1 parent 1851b81 commit c52c390

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

versioned_docs/version-7.x/elements.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,3 +831,17 @@ Helper that returns the title text to use in header. It takes the following para
831831

832832
- `options` - The options object of the screen.
833833
- `fallback` - Fallback title string if no title was found in options.
834+
835+
### `useFrameSize`
836+
837+
Hook that returns the size of the frame of the parent navigator. It accepts a selector function which receives the frame dimensions and returns a value:
838+
839+
```js
840+
import { useFrameSize } from '@react-navigation/elements';
841+
842+
// ...
843+
844+
const isLandscape = useFrameSize((frame) => frame.width > frame.height);
845+
```
846+
847+
The selector ensures that the component only re-renders when we need to.

0 commit comments

Comments
 (0)