Skip to content

Commit

Permalink
chore: reset _isJsLayoutComplete on layout changes #49
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaup committed Nov 10, 2024
1 parent e423b28 commit f705801
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/LazyChild/components/FullLazyChild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export function FullLazyChild({

function measureView() {
'worklet';

const measurement = measure(_viewRef);

if (_debug.value) {
Expand Down Expand Up @@ -142,6 +143,13 @@ export function FullLazyChild({
});

const onLayout = useCallback(({ nativeEvent }: LayoutChangeEvent) => {
if (
_isJsLayoutComplete.value &&
(!nativeEvent.layout.height || !nativeEvent.layout.width)
) {
_isJsLayoutComplete.value = false;
}

// Don't measure until we know we have something.
if (nativeEvent.layout.height > 0 || nativeEvent.layout.width > 0) {
// onLayout runs when RN finishes render, but native layout may not be fully settled until the next frame.
Expand Down

0 comments on commit f705801

Please sign in to comment.