UNPKG

@scrolia/react-native-flash-list

Version:

A set of list components for Scrolia React Native

45 lines (41 loc) 1.34 kB
"use client"; import { useScrollCore } from "@scrolia/react-native/contexts/scrollcore"; import { getComponentProps } from "@scrolia/react-native/functions/props"; import { useContentYHandler } from "@scrolia/react-native/hooks/content"; import { FlashList } from "@shopify/flash-list"; import * as React from "react"; import { jsx } from "react/jsx-runtime"; /** * Vertical list component based on `@shopify/flash-list`. * * **This component requires `@shopify/flash-list` to be installed.** */ const FlashListY = (props) => { const { options: { disabled, plugins }, y: { contentType, contentRef } } = 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 }); return /* @__PURE__ */ jsx(FlashList, { ...p, ref: contentRef, showsHorizontalScrollIndicator: false, showsVerticalScrollIndicator: p.showsHorizontalScrollIndicator ?? disabled, onLayout, onContentSizeChange, onScroll, horizontal: false, scrollEventThrottle: p.scrollEventThrottle ?? 5, children: p.children }); }; export { FlashListY }; //# sourceMappingURL=y.mjs.map