Skip to content

Instantly share code, notes, and snippets.

@itispx
Last active November 10, 2022 02:19
Show Gist options
  • Save itispx/2f4c0e120dfc494e89618445933f9536 to your computer and use it in GitHub Desktop.
Save itispx/2f4c0e120dfc494e89618445933f9536 to your computer and use it in GitHub Desktop.
useStatusBarStyle hook
import { useEffect } from "react";
import { StatusBar } from "react-native";
/**
*
* @param {"light-content" | "dark-content" | "default"} style
* @param {"light-content" | "dark-content" | "default"} cleanup
*/
const useStatusBarStyle = (style, cleanup) => {
useEffect(() => {
StatusBar.setBarStyle(style);
return () => cleanup && StatusBar.setBarStyle(cleanup);
}, []);
};
export default useStatusBarStyle;
import { useEffect } from "react";
import { StatusBar } from "react-native";
const useStatusBarStyle = (
style: "light-content" | "dark-content" | "default",
cleanup?: "light-content" | "dark-content" | "default"
) => {
useEffect(() => {
StatusBar.setBarStyle(style);
return () => cleanup && StatusBar.setBarStyle(cleanup);
}, []);
};
export default useStatusBarStyle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment