'TypeScript type for onLayout event in React Native?

How can I specify a type in TypeScript for React Native's onLayout event?

  const handleOnLayout = (e: SomeTypeHere) => {
    // stuff
  };

  <View onLayout={handleOnLayout}>
    <Text>Hi</Text>
  </View>


Solution 1:[1]

Murmletiers link to the source was helpful! I am using LayoutRectangle now as it is the type definition that I was looking for:

   export interface LayoutRectangle {
        x: number;
        y: number;
        width: number;
        height: number;
    }

    // @see TextProperties.onLayout
    export interface LayoutChangeEvent {
        nativeEvent: {
            layout: LayoutRectangle
        }
    }

used like this

import { LayoutRectangle } from "react-native";

const [layout, setLayout] = useState<LayoutRectangle>();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael Brenndoerfer