UNPKG

@scrolia/react-native

Version:
44 lines (41 loc) 1.23 kB
"use client"; import { useScrollCore } from "../../contexts/scrollcore.mjs"; import { getComponentProps } from "../../functions/props.mjs"; import { useContentXHandler } from "../../hooks/content/index.mjs"; import { FlatList } from "react-native"; import * as React from "react"; import { jsx } from "react/jsx-runtime"; /** * Horizontal list component. * * Use `ContentX` for generic content. */ const ListX = (props) => { const { options: { disabled, plugins }, x: { contentRef, contentType } } = 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(FlatList, { ...p, ref: contentRef, showsHorizontalScrollIndicator: p.showsHorizontalScrollIndicator ?? disabled, showsVerticalScrollIndicator: false, onLayout, onContentSizeChange, onScroll, horizontal: true, scrollEventThrottle: p.scrollEventThrottle ?? 5, children: p.children }); }; export { ListX }; //# sourceMappingURL=x.mjs.map