KeyboardAvoidingView not Working Properly

前端 未结 14 2397
悲&欢浪女
悲&欢浪女 2020-12-02 08:51

KeyboardAvoidingView not Working Properly

I am trying to use the KeyboardAvoidingView with behavior="padding".

For some reason, when I

14条回答
  •  情书的邮戳
    2020-12-02 09:55

    I think the best approach is to create a HOC for this, in addition ,by using getBottomSpace from react-native-iphone-x-helper you can solve overlapping issue for IPhone X and..

     import React, { ComponentType, ReactNode } from 'react';
        import { Platform, KeyboardAvoidingView, View, Pressable, Keyboard } from 
        'react-native';
        import { getBottomSpace } from 'react-native-iphone-x-helper';
    
        interface IProps {
        children: ReactNode;
        }
    
        const KeyboardAvoidingViewHoc = (Component: ComponentType) => {
        return ({ children, ...props }: IProps) => {
        return (
          
            
              {children}
            
          
        );
      };
    };
    
    export const AvoidKeyboardAvoidingViewHoc = KeyboardAvoidingViewHoc(View);
    

提交回复
热议问题