File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed
Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -13,18 +13,18 @@ const useKeyboard = (isEnable = true): [number] => {
1313 }
1414
1515 useEffect ( ( ) => {
16- const keyboardShowEvent =
17- Platform . OS === 'android' ? 'keyboardDidShow' : 'keyboardWillShow' ;
18- const keyboardHideEvent =
19- Platform . OS === 'android' ? 'keyboardDidHide' : 'keyboardWillHide' ;
2016 if ( isEnable ) {
21- Keyboard . addListener ( keyboardShowEvent , onKeyboardWillShow ) ;
22- Keyboard . addListener ( keyboardHideEvent , onKeyboardWillHide ) ;
17+ const keyboardShowEvent =
18+ Platform . OS === 'android' ? 'keyboardDidShow' : 'keyboardWillShow' ;
19+ const keyboardHideEvent =
20+ Platform . OS === 'android' ? 'keyboardDidHide' : 'keyboardWillHide' ;
21+ const showSubscription = Keyboard . addListener ( keyboardShowEvent , onKeyboardWillShow ) ;
22+ const hideSubscription = Keyboard . addListener ( keyboardHideEvent , onKeyboardWillHide ) ;
23+ return ( ) : void => {
24+ showSubscription . remove ( ) ;
25+ hideSubscription . remove ( ) ;
26+ } ;
2327 }
24- return ( ) : void => {
25- Keyboard . removeListener ( keyboardShowEvent , onKeyboardWillShow ) ;
26- Keyboard . removeListener ( keyboardHideEvent , onKeyboardWillHide ) ;
27- } ;
2828 } , [ isEnable ] ) ;
2929
3030 return [ keyboardHeight ] ;
You can’t perform that action at this time.
0 commit comments