Files
mini-programs/src/container/listContainer/index.tsx
2025-09-01 00:03:43 +08:00

46 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { View, Text } from "@tarojs/components";
import ListCard from "@/components/ListCard";
import ListLoadError from "@/components/ListLoadError";
import ListCardSkeleton from "@/components/ListCardSkeleton";
import "./index.scss";
const ListContainer = (props) => {
const { loading, data = [], error, reload, recommendList } = props;
if (error) {
return <ListLoadError reload={reload} />;
}
const renderList = (list) => {
if (loading && list.length === 0) {
return (
<>
{new Array(10).fill(0).map(() => {
return <ListCardSkeleton />;
})}
</>
);
}
return (
<>
{list?.map((match, index) => (
<ListCard key={match.id || index} {...match} />
))}
</>
);
};
return (
<View className="listContentWrapper">
{renderList(data)}
<View className="recommendTextWrapper">
<Text className="recommendText"></Text>
</View>
{renderList(recommendList)}
</View>
);
};
export default ListContainer;