From e46682f508f90887eb79a6053fb5ad8e080a0be9 Mon Sep 17 00:00:00 2001 From: Leon Xu Date: Sun, 29 Jan 2023 19:44:34 -0800 Subject: [PATCH] doc: added RenderCards method --- src/pages/Home.jsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index ff3ab95..a0308e7 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -1,6 +1,15 @@ import React, { useState, useEffect } from "react"; import { Loader, Card, FormField } from "../components"; +const RenderCards = ({ data, title }) => { + if (data?.length > 0) { + return data.map((post) => ); + } + return ( +

{title}

+ ); +}; + const Home = () => { const [loading, setLoading] = useState(false); const [allPosts, setAllPosts] = useState(null); @@ -35,6 +44,13 @@ const Home = () => { {searchText} )} +
+ {searchText ? ( + + ) : ( + + )} +
)}