Skip to content

Instantly share code, notes, and snippets.

@tpjnorton
Created October 23, 2020 09:16
Show Gist options
  • Save tpjnorton/1cc9b95e1216aca748539eda05866b7e to your computer and use it in GitHub Desktop.
Save tpjnorton/1cc9b95e1216aca748539eda05866b7e to your computer and use it in GitHub Desktop.
import { useEffect, useCallback } from 'react';
import { StatusBar } from 'react-native';
import { useFocusEffect } from '@react-navigation/native'
const useStatusBar = ({ style, backgroundColor, translucent, hidden }) => {
useFocusEffect(
useCallback(() => {
style && StatusBar.setBarStyle(style, true);
backgroundColor && StatusBar.setBackgroundColor(backgroundColor, true);
translucent && StatusBar.setTranslucent(translucent);
hidden && StatusBar.setHidden(hidden);
}, [])
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment