Skip to main content

useHeader

Useful if you want to set the title, or change back button behaviour in React Navigation.

import React, { useLayoutEffect } from 'react';

type HeaderProps = NavigationStackParams;

const useHeader = (headerProps: HeaderProps, deps: any[] = []) => {
const navigation = useNavigation();

useLayoutEffect(() => {
navigation.setOptions({
headerShown: true,
...headerProps
});
}, deps);
};

Usage

useHeader({ title: "DEF", ...otherReactNavigationStuffs});