@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.x.elRef.current, [
core.x.elRef
]);
useEffect(()=>{
core.x.elType.current = "flatlist";
}, [
core.x.elType
]);
const handleLayout = (event)=>{
if (!core.options.disabled) core.x.handleLayout(event);
p.onLayout?.(event);
};
const handleContentSizeChange = (width, height)=>{
if (!core.options.disabled) core.x.handleContentSizeChange(width, height);
p.onContentSizeChange?.(width, height);
};
const handleScroll = (event)=>{
if (!core.options.disabled) core.x.handleScroll(event);
p.onScroll?.(event);
};
return /*#__PURE__*/ jsx(Fragment, {
children: /*#__PURE__*/ jsx(FlashList, {
...p,
ref: core.x.elRef,
showsHorizontalScrollIndicator: core.options.disabled,
showsVerticalScrollIndicator: false,
onLayout: handleLayout,
onContentSizeChange: handleContentSizeChange,
onScroll: handleScroll,
horizontal: true,
scrollEventThrottle: p.scrollEventThrottle ?? 5,
children: children
})
});
};
const FlashListX = /*#__PURE__*/ forwardRef(List);
FlashListX.displayName = "FlashListX";
export { FlashListX };
//# sourceMappingURL=x.mjs.map