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 { useContentYHandler } from "../../hooks/content/index.mjs"; import { FlatList } from "react-native"; import * as React from "react"; import { jsx } from "react/jsx-runtime"; /** * Vertical list component. * * Use `ContentY` for generic content. */ const ListY = (props) => { const { options: { disabled, plugins }, y: { contentRef, contentType } } = useScrollCore(); const p = getComponentProps({ name: "listY", props, plugins }); React.useImperativeHandle(p.ref, () => { return contentRef.current; }, [contentRef]); React.useEffect(() => { contentType.current = "flatlist"; }, [contentType]); const { onLayout, onContentSizeChange, onScroll } = useContentYHandler({ props: p }); return /* @__PURE__ */ jsx(FlatList, { ...p, ref: contentRef, showsHorizontalScrollIndicator: false, showsVerticalScrollIndicator: p.showsHorizontalScrollIndicator ?? disabled, onLayout, onContentSizeChange, onScroll, horizontal: false, scrollEventThrottle: p.scrollEventThrottle ?? 5, children: p.children }); }; export { ListY }; //# sourceMappingURL=y.mjs.map