@scrolia/react-native-flash-list
Version:
A set of list components for Scrolia React Native
48 lines (47 loc) • 1.67 kB
JavaScript
"use client";
import { Fragment, jsx } from "react/jsx-runtime";
import { useScrollCore } from "@scrolia/react-native-core";
import { FlashList } from "@shopify/flash-list";
import { forwardRef, useEffect, useImperativeHandle } from "react";
const List = (props, ref)=>{
const { children, ...p } = props;
const core = useScrollCore();
useImperativeHandle(ref, ()=>core.y.elRef.current, [
core.y.elRef
]);
useEffect(()=>{
core.y.elType.current = "flatlist";
}, [
core.y.elType
]);
const handleLayout = (event)=>{
if (!core.options.disabled) core.y.handleLayout(event);
p.onLayout?.(event);
};
const handleContentSizeChange = (width, height)=>{
if (!core.options.disabled) core.y.handleContentSizeChange(width, height);
p.onContentSizeChange?.(width, height);
};
const handleScroll = (event)=>{
if (!core.options.disabled) core.y.handleScroll(event);
p.onScroll?.(event);
};
return /*#__PURE__*/ jsx(Fragment, {
children: /*#__PURE__*/ jsx(FlashList, {
...p,
ref: core.y.elRef,
showsHorizontalScrollIndicator: false,
showsVerticalScrollIndicator: core.options.disabled,
onLayout: handleLayout,
onContentSizeChange: handleContentSizeChange,
onScroll: handleScroll,
horizontal: false,
scrollEventThrottle: p.scrollEventThrottle ?? 5,
children: children
})
});
};
const FlashListY = /*#__PURE__*/ forwardRef(List);
FlashListY.displayName = "FlashListY";
export { FlashListY };
//# sourceMappingURL=y.mjs.map