Skip to content

Instantly share code, notes, and snippets.

@mortocks
Last active July 6, 2020 13:28
Show Gist options
  • Save mortocks/b89ab2ec538b4e5e5a374972c56d1681 to your computer and use it in GitHub Desktop.
Save mortocks/b89ab2ec538b4e5e5a374972c56d1681 to your computer and use it in GitHub Desktop.
Sets the status bar style on navigation through hooks.#react-native
import { useCallback } from 'react';
import { StatusBar } from 'react-native';
import { useFocusEffect } from '@react-navigation/native';
/**
* Sets the status bar style on navigation through hooks
* @param { String } style The status bar style light-content dark-content
*/
const useStatusBarStyle = style => {
useFocusEffect(
useCallback(() => {
StatusBar.setBarStyle(style);
}, [])
);
}
export default useStatusBarStyle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment