Created
October 14, 2022 06:19
-
-
Save itispx/a89b3602a098cad8a294d252d99a44cc to your computer and use it in GitHub Desktop.
useOnScreenIsLeft hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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