简体   繁体   中英

React Native | How access to endCoordinates of Keyboard using Typescript and recompose

So I use recompoose and typescript in my react native app, and I trying to access to endCoordinates for Keyboard the get the Keyboard height. I followed this article and this post but I am not able to access to endCoordinates, it's always undefined.

This is what I tried :

const withLifeCycle = lifecycle<Handlers, {}> ({
     componentDidMount() {
        // @ts-ignore
        this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this.props._keyboardDidShow)
},
 componentWillUnmount() {
   // @ts-ignore
   this.keyboardDidShowListener.remove();
 }
})    


interface Handlers {
  _keyboardDidShow: (e:any) => void;
}
// WrappedProps have some other props for some other part of codes

export const enhance = compose<WrappedProps, Props>(
withHandlers<
Props,
{}
>({
  _keyboardDidShow: (e) => () =>{
     console.log(e.endCoordinates) // This is Undefined
   }
 }),
 withLifeCycle
);

I think the problem is the way I need to pass the keyboardDidShow event type to the method, because e object does not have any endCoordinates .

react-native导入KeyboardEvent

const _keyboardDidShow = (props: KeyboardEvent)

const { endCoordinates } = props;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM