Skip to content

Instantly share code, notes, and snippets.

@itispx
Created October 14, 2022 06:19
Show Gist options
  • Save itispx/a89b3602a098cad8a294d252d99a44cc to your computer and use it in GitHub Desktop.
Save itispx/a89b3602a098cad8a294d252d99a44cc to your computer and use it in GitHub Desktop.
useOnScreenIsLeft hook
import { useEffect } from "react";
import { useNavigation } from "@react-navigation/native";
const useOnScreenIsLeft = (func, dependencies) => {
const navigation = useNavigation();
useEffect(() => {
const unsubscribe = navigation.addListener("blur", () => {
func();
});
return unsubscribe;
}, [navigation, dependencies]);
};
export default useOnScreenIsLeft;
import { useEffect } from "react";
import { useNavigation } from "@react-navigation/native";
const useOnScreenIsLeft = (func: () => void, dependencies: [] | undefined) => {
const navigation = useNavigation();
useEffect(() => {
const unsubscribe = navigation.addListener("blur", () => {
func();
});
return unsubscribe;
}, [navigation, dependencies]);
};
export default useOnScreenIsLeft;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment