In order to flowtype events, I define custom types like the following:
export type OnScrollEvent = {
nativeEvent: {
contentOffset: {
y: number
},
contentSize: {
height: number
}
}
}
Obviously, there are several missing properties (like x and width), but I have no need for them yet.
I have tried to locate similar types for RN but only found an Event type that does not seem to be particularly useful:
import type {Event} from "react-native";
handleEvent = (e: Event) => console.log(e.inexistentProperty) // Flow doesn't care!
Are there any existing flow types for React Native events or do I have to keep defining them myself?
Update
They seem to be scattered around the code base. Here's the layout event type:
export type ViewLayout = {
x: number,
y: number,
width: number,
height: number,
}
export type ViewLayoutEvent = {
nativeEvent: {
layout: ViewLayout,
}
}
found in ViewPropTypes.js