Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions docs/the-new-architecture/layout-measurements.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ The best way to invoke those methods is in a `useLayoutEffect` hook: this will g
Typical code will look like this:

```tsx
function AComponent(children) {
const targetRef = useRef(null)

useLayoutEffect(() => {
targetRef.current?.measure((x, y, width, height, pageX, pageY) => {
//do something with the measurements
});
}, [ /* add dependencies here */]);

return (
<View ref={targetRef}>
{children}
<View />
function AComponent({children}) {
const targetRef = useRef(null);

useLayoutEffect(
() => {
targetRef.current?.measure(
(x, y, width, height, pageX, pageY) => {
//do something with the measurements
},
);
},
[/* add dependencies here */],
);

return <View ref={targetRef}>{children}</View>;
}
```

Expand Down