Skip to content

Commit 0b0348a

Browse files
committed
fix: store typeof values in shared values
1 parent e1e181a commit 0b0348a

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/components/LazyChild/components/FullLazyChild.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,30 @@ export function FullLazyChild({
5555

5656
const _debug = useSharedValue(debug);
5757

58+
const _hasOnEnterCallback = useSharedValue(
59+
typeof onEnterThresholdPass === 'function'
60+
);
61+
const _hasOnExitCallback = useSharedValue(
62+
typeof onExitThresholdPass === 'function'
63+
);
64+
const _hasOnVisibilityEnterCallback = useSharedValue(
65+
typeof onVisibilityEnter === 'function'
66+
);
67+
const _hasOnVisibilityExitCallback = useSharedValue(
68+
typeof onVisibilityExit === 'function'
69+
);
70+
5871
const shouldFireThresholdEnter = useDerivedValue(() => {
59-
return typeof onEnterThresholdPass === 'function' && !isScrollUnmounted;
72+
return _hasOnEnterCallback.value && !isScrollUnmounted.value;
6073
});
6174
const shouldFireThresholdExit = useDerivedValue(() => {
62-
return typeof onExitThresholdPass === 'function' && !isScrollUnmounted;
75+
return _hasOnExitCallback.value && !isScrollUnmounted.value;
6376
});
6477
const shouldMeasurePercentVisible = useDerivedValue(() => {
65-
return typeof onVisibilityEnter === 'function' && !isScrollUnmounted;
78+
return _hasOnVisibilityEnterCallback.value && !isScrollUnmounted.value;
6679
});
6780
const shouldFireVisibilityExit = useDerivedValue(() => {
68-
return typeof onVisibilityExit === 'function' && !isScrollUnmounted;
81+
return _hasOnVisibilityExitCallback.value && !isScrollUnmounted.value;
6982
});
7083

7184
const _hasValidCallback = useDerivedValue(

0 commit comments

Comments
 (0)