Skip to content

Instantly share code, notes, and snippets.

@itispx
Created October 14, 2022 06:18
Show Gist options
  • Save itispx/37e3cc2df0ffdb2835e774c1f51992d7 to your computer and use it in GitHub Desktop.
Save itispx/37e3cc2df0ffdb2835e774c1f51992d7 to your computer and use it in GitHub Desktop.
useHeaderHeight hook
import { getDefaultHeaderHeight } from "@react-navigation/elements";
import {
useSafeAreaFrame,
useSafeAreaInsets,
} from "react-native-safe-area-context";
const useHeaderHeight = () => {
const frame = useSafeAreaFrame();
const insets = useSafeAreaInsets();
const height = getDefaultHeaderHeight(frame, false, insets.top);
return height;
};
export default useHeaderHeight;
import { getDefaultHeaderHeight } from "@react-navigation/elements";
import {
useSafeAreaFrame,
useSafeAreaInsets,
} from "react-native-safe-area-context";
const useHeaderHeight = (): number => {
const frame = useSafeAreaFrame();
const insets = useSafeAreaInsets();
const height = getDefaultHeaderHeight(frame, false, insets.top);
return height;
};
export default useHeaderHeight;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment