diff --git a/README.md b/README.md index 1b2ea981..f76b0a7d 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ useBackHandler(() => { } // let the default thing happen return false -}) +},[shouldBeHandledHere]) ``` ### `useCameraRoll` diff --git a/src/useBackHandler.ts b/src/useBackHandler.ts index 470150db..b39a4c20 100644 --- a/src/useBackHandler.ts +++ b/src/useBackHandler.ts @@ -1,10 +1,11 @@ -import {useEffect} from 'react' +import {useEffect, DependencyList} from 'react' import {BackHandler} from 'react-native' -export function useBackHandler(handler: () => boolean) { +export function useBackHandler(handler: () => boolean, deps?: DependencyList) { useEffect(() => { BackHandler.addEventListener('hardwareBackPress', handler) return () => BackHandler.removeEventListener('hardwareBackPress', handler) - }, [handler]) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, deps) }