MCPcopy
hub / github.com/react-native-community/hooks / useLayout

Function useLayout

src/useLayout.ts:4–18  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import { LayoutChangeEvent, LayoutRectangle } from "react-native"
3
4export 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}

Callers 1

useLayout.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected