Skip to content

Commit

Permalink
chore: remove unused content wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaup committed Oct 24, 2024
1 parent c76ef33 commit 358be76
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions src/components/LazyScrollView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ import React, {
useCallback,
useImperativeHandle,
useMemo,
useRef,
} from 'react';
import {
ScrollView,
StatusBar,
View,
type LayoutChangeEvent,
} from 'react-native';
import { ScrollView, StatusBar, type LayoutChangeEvent } from 'react-native';
import Animated, {
measure,
runOnJS,
Expand Down Expand Up @@ -62,11 +56,9 @@ type Props = LazyScrollViewProps &
const LazyScrollView = forwardRef<LazyScrollViewMethods, Props>(
({ children, offset: injectedOffset, debug = false, ...rest }, ref) => {
const _scrollRef = useAnimatedRef<Animated.ScrollView>();
const _wrapperRef = useRef<View>(null);
const _offset = useSharedValue(injectedOffset || 0);
const _containerDimensions = useSharedValue({ width: 0, height: 0 });
const _containerCoordinates = useSharedValue({ x: 0, y: 0 });
const _contentDimensions = useSharedValue({ width: 0, height: 0 });
const _statusBarHeight = useSharedValue(StatusBar.currentHeight || 0);
const _debug = useSharedValue(debug);
const horizontal = useSharedValue(!!rest.horizontal);
Expand Down Expand Up @@ -150,23 +142,6 @@ const LazyScrollView = forwardRef<LazyScrollViewMethods, Props>(
[]
);

const measureContent = useCallback(
(e: LayoutChangeEvent) => {
const dimensions = {
height: e.nativeEvent.layout.height,
width: e.nativeEvent.layout.width,
};

if (debug) {
log('content dimensions:', dimensions);
}

_contentDimensions.value = dimensions;
},
// eslint-disable-next-line react-hooks/exhaustive-deps -- shared values do not trigger re-renders
[]
);

const value = useMemo(
() => ({
_hasProvider: true,
Expand All @@ -189,9 +164,7 @@ const LazyScrollView = forwardRef<LazyScrollViewMethods, Props>(
onLayout={measureScrollView}
>
<AnimatedContext.Provider value={value}>
<View ref={_wrapperRef} onLayout={measureContent}>
{children}
</View>
{children}
</AnimatedContext.Provider>
</Animated.ScrollView>
);
Expand Down

0 comments on commit 358be76

Please sign in to comment.