Skip to content

Commit 56bdf51

Browse files
pvinishosseinmd
andauthored
#201 rebase (#418)
Co-authored-by: Hossein Mohammadi <[email protected]>
1 parent e6e8ec5 commit 56bdf51

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.changeset/old-pianos-find.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-native-community/hooks": minor
3+
---
4+
5+
dep list on useBackHandler

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ useBackHandler(() => {
6969
}
7070
// let the default thing happen
7171
return false
72-
})
72+
},[shouldBeHandledHere])
7373
```
7474

7575
### `useImageDimensions`

src/useBackHandler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { useEffect } from "react"
1+
import { DependencyList, useEffect } from "react"
22
import { BackHandler } from "react-native"
33

4-
export function useBackHandler(handler: () => boolean) {
4+
export function useBackHandler(handler: () => boolean, deps: DependencyList = []) {
55
useEffect(() => {
6-
const subscription = BackHandler.addEventListener("hardwareBackPress", handler)
6+
const sub = BackHandler.addEventListener("hardwareBackPress", handler)
77

8-
return () => subscription.remove()
9-
}, [handler])
8+
return () => sub.remove()
9+
}, [handler, ...deps])
1010
}

0 commit comments

Comments
 (0)