File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
package/src/components/AttachmentPicker Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -248,13 +248,18 @@ export const AttachmentPicker = React.forwardRef(
248248 } , [ selectedPicker ] ) ;
249249
250250 useEffect ( ( ) => {
251- if ( Platform . OS === 'ios' ) {
252- Keyboard . addListener ( 'keyboardWillShow' , hideAttachmentPicker ) ;
253- } else {
254- Keyboard . addListener ( 'keyboardDidShow' , hideAttachmentPicker ) ;
255- }
251+ const keyboardSubscription =
252+ Platform . OS === 'ios'
253+ ? Keyboard . addListener ( 'keyboardWillShow' , hideAttachmentPicker )
254+ : Keyboard . addListener ( 'keyboardDidShow' , hideAttachmentPicker ) ;
256255
257256 return ( ) => {
257+ if ( keyboardSubscription ?. remove ) {
258+ keyboardSubscription . remove ( ) ;
259+ return ;
260+ }
261+
262+ // To keep compatibility with older versions of React Native, where `remove()` is not available
258263 if ( Platform . OS === 'ios' ) {
259264 Keyboard . removeListener ( 'keyboardWillShow' , hideAttachmentPicker ) ;
260265 } else {
You can’t perform that action at this time.
0 commit comments