Skip to content

Commit

Permalink
fix: store typeof values in shared values
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaup committed Feb 8, 2025
1 parent e1e181a commit 0b0348a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/components/LazyChild/components/FullLazyChild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,30 @@ export function FullLazyChild({

const _debug = useSharedValue(debug);

const _hasOnEnterCallback = useSharedValue(
typeof onEnterThresholdPass === 'function'
);
const _hasOnExitCallback = useSharedValue(
typeof onExitThresholdPass === 'function'
);
const _hasOnVisibilityEnterCallback = useSharedValue(
typeof onVisibilityEnter === 'function'
);
const _hasOnVisibilityExitCallback = useSharedValue(
typeof onVisibilityExit === 'function'
);

const shouldFireThresholdEnter = useDerivedValue(() => {
return typeof onEnterThresholdPass === 'function' && !isScrollUnmounted;
return _hasOnEnterCallback.value && !isScrollUnmounted.value;
});
const shouldFireThresholdExit = useDerivedValue(() => {
return typeof onExitThresholdPass === 'function' && !isScrollUnmounted;
return _hasOnExitCallback.value && !isScrollUnmounted.value;
});
const shouldMeasurePercentVisible = useDerivedValue(() => {
return typeof onVisibilityEnter === 'function' && !isScrollUnmounted;
return _hasOnVisibilityEnterCallback.value && !isScrollUnmounted.value;
});
const shouldFireVisibilityExit = useDerivedValue(() => {
return typeof onVisibilityExit === 'function' && !isScrollUnmounted;
return _hasOnVisibilityExitCallback.value && !isScrollUnmounted.value;
});

const _hasValidCallback = useDerivedValue(
Expand Down

0 comments on commit 0b0348a

Please sign in to comment.