File tree 3 files changed +11
-6
lines changed 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @react-native-community/hooks " : minor
3
+ ---
4
+
5
+ dep list on useBackHandler
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ useBackHandler(() => {
69
69
}
70
70
// let the default thing happen
71
71
return false
72
- })
72
+ },[shouldBeHandledHere] )
73
73
```
74
74
75
75
### ` useImageDimensions `
Original file line number Diff line number Diff line change 1
- import { useEffect } from "react"
1
+ import { DependencyList , useEffect } from "react"
2
2
import { BackHandler } from "react-native"
3
3
4
- export function useBackHandler ( handler : ( ) => boolean ) {
4
+ export function useBackHandler ( handler : ( ) => boolean , deps : DependencyList = [ ] ) {
5
5
useEffect ( ( ) => {
6
- const subscription = BackHandler . addEventListener ( "hardwareBackPress" , handler )
6
+ const sub = BackHandler . addEventListener ( "hardwareBackPress" , handler )
7
7
8
- return ( ) => subscription . remove ( )
9
- } , [ handler ] )
8
+ return ( ) => sub . remove ( )
9
+ } , [ handler , ... deps ] )
10
10
}
You can’t perform that action at this time.
0 commit comments