Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuever committed Jan 12, 2025
1 parent 1ead374 commit fb08bf2
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions ui/scroller/src/react-native/item/createViewableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ import React, {
useMemo,
useRef,
} from 'react';
import { ViewStyle, StyleSheet } from 'react-native';
import { ViewStyle, StyleSheet, LayoutChangeEvent } from 'react-native';

import ScrollViewContext from '../context/ScrollViewContext';
// import ViewabilityContext from '../context/ViewabilityContext';
// import ViewableItemContext from '../context/ViewableItemContext';
// import useBindGeneral from '../hooks/useBindGeneral';
// import useMeasureLayout from '../hooks/useMeasureLayout';
import { ViewableItemProps } from '../types';
// import MemoedViewableItem from './Item';

const createViewableComponent = <T extends React.ComponentType<any>>(
Component: T
Expand All @@ -34,13 +29,6 @@ const createViewableComponent = <T extends React.ComponentType<any>>(
containerKey,
CellRendererComponent,
viewableItemHelperKey,
isIntervalTreeItem = false,
setMeasureLayoutHandler,
onMeasureLayout: _onMeasureLayout,
measureLayoutHandlerOnDemand,
getMetaOnViewableItemsChanged,
viewAbilityPropsSensitive = true,
itemKey,
...rest
} = props;
const containerStyle = useMemo<ViewStyle>(
Expand All @@ -64,11 +52,15 @@ const createViewableComponent = <T extends React.ComponentType<any>>(
}
}, [intersectionObserver]);

const layoutHandler = useCallback(() => {
if (intersectionObserver) {
intersectionObserver.updateClientRect(viewRef.current);
}
}, [intersectionObserver]);
const layoutHandler = useCallback(
(e: LayoutChangeEvent) => {
onLayout(e);
if (intersectionObserver) {
intersectionObserver.updateClientRect(viewRef.current);
}
},
[intersectionObserver]
);

const RenderComponent = useMemo(
() => CellRendererComponent || Component,
Expand Down

0 comments on commit fb08bf2

Please sign in to comment.