import React, { createContext, ReactNode, useContext, useState } from "react"; import { Dimensions, View } from "react-native"; const KeyboardAvoidingContext = createContext<{ appHeight: number }>({ appHeight: 0 }) export default function KeyboardAvoiderProvider({ children, }: { children: ReactNode }) { const [appHeight, setAppHeight] = useState(Dimensions.get('window').height); return ( setAppHeight(e.nativeEvent.layout.height)} > {children} ) } export function useAppHeight() { return useContext(KeyboardAvoidingContext); }