@scrolia/react-native-flash-list
Version:
A set of list components for Scrolia React Native
45 lines (41 loc) • 1.35 kB
JavaScript
"use client";
import { useScrollCore } from "@scrolia/react-native/contexts/scrollcore";
import { getComponentProps } from "@scrolia/react-native/functions/props";
import { useContentXHandler } from "@scrolia/react-native/hooks/content";
import { FlashList } from "@shopify/flash-list";
import * as React from "react";
import { jsx } from "react/jsx-runtime";
/**
* Horizontal list component based on `@shopify/flash-list`.
*
* **This component requires `@shopify/flash-list` to be installed.**
*/
const FlashListX = (props) => {
const { options: { disabled, plugins }, x: { contentType, contentRef } } = useScrollCore();
const p = getComponentProps({
name: "listX",
props,
plugins
});
React.useImperativeHandle(p.ref, () => {
return contentRef.current;
}, [contentRef]);
React.useEffect(() => {
contentType.current = "flatlist";
}, [contentType]);
const { onLayout, onContentSizeChange, onScroll } = useContentXHandler({ props: p });
return /* @__PURE__ */ jsx(FlashList, {
...p,
ref: contentRef,
showsHorizontalScrollIndicator: p.showsHorizontalScrollIndicator ?? disabled,
showsVerticalScrollIndicator: false,
onLayout,
onContentSizeChange,
onScroll,
horizontal: true,
scrollEventThrottle: p.scrollEventThrottle ?? 5,
children: p.children
});
};
export { FlashListX };
//# sourceMappingURL=x.mjs.map