()
| 2 | import { LayoutChangeEvent, LayoutRectangle } from "react-native" |
| 3 | |
| 4 | export function useLayout() { |
| 5 | const [layout, setLayout] = useState<LayoutRectangle>({ |
| 6 | x: 0, |
| 7 | y: 0, |
| 8 | width: 0, |
| 9 | height: 0, |
| 10 | }) |
| 11 | |
| 12 | const onLayout = useCallback((e: LayoutChangeEvent) => setLayout(e.nativeEvent.layout), []) |
| 13 | |
| 14 | return { |
| 15 | onLayout, |
| 16 | ...layout, |
| 17 | } |
| 18 | } |