/* * @Description: * @Author: jiass * @Date: 2022-01-25 13:29:21 * @LastEditTime: 2022-04-08 16:17:45 * @LastEditors: lanzhisheng */ import React, { FC } from "react"; import { useState } from "react"; import { View, ScrollView } from "@tarojs/components"; const SharesView: FC = (props) => { const { data, onClick, onBottom, style, columns, hasMore } = props; const [hasScrollY, sethasScrollY] = useState(false); const handleGo = (item) => { onClick(item); }; const onScrollToLower = () => { if (hasScrollY && hasMore) { onBottom && onBottom(); } }; const onScroll = (e) => { if (e.detail.deltaY) { sethasScrollY(true); } else { sethasScrollY(false); } }; return ( { onScroll(e); }} lowerThreshold={50} onScrollToLower={onScrollToLower} className="container" style={style} > {columns.map((itemS) => ( {itemS?.name} ))} {data.map((item) => ( { handleGo(item); }} > {columns.map((itemS) => ( {itemS.render ? itemS.render(item[itemS.sortField], item) : item[itemS.sortField]} ))} ))} ); }; export default SharesView;