th3rdwave / react-native-safe-area-context

A flexible way to handle safe area insets in JS. Also works on Android and Web!
MIT License
2.14k stars 197 forks source link

Proposal of imperative API - useSafeAreaGetLatestWindowMetrics #428

Closed Noitidart closed 1 year ago

Noitidart commented 1 year ago

Summary

The name I matched to initialWindowMetrics that is exported. The hook name is kind of long.

This offers a way for users to get the latest window metrics.

Usage:

const getLatestWindowMetrics = useSafeAreaGetLatestWindowMetrics();

// getLatestWindowMetrics is now stable and can be used in effects, worklets, etc, without worrying to re-render.

Test Plan

Just a proposal for now. If accepted will add tests.