Skip to content

Commit 53650ca

Browse files
committed
Update App.jsx
1 parent b68ea37 commit 53650ca

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/App.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const cards = [
2626
];
2727

2828
function App() {
29-
let filterCards = [];
29+
const [filterCards, setFilterCards] = useState(cards);
30+
3031
const cardsJSX = filterCards.map((card) => (
3132
<Card
3233
title={card.title}
@@ -35,26 +36,28 @@ function App() {
3536
forks={card.forks}
3637
/>
3738
));
38-
console.log("render");
39+
console.log("render", filterCards);
3940
return (
4041
<>
4142
<Header />
4243
<main>
4344
<SearchBar
4445
onSearch={(value) => {
4546
console.log(value);
47+
const items = [];
4648
for (let i = 0; i < cards.length; i++) {
4749
if (
4850
cards[i].title.includes(value) ||
4951
cards[i].description.includes(value)
5052
) {
51-
filterCards.push(cards[i]);
53+
items.push(cards[i]);
5254
}
5355
}
54-
console.log(filterCards);
56+
console.log(items);
57+
setFilterCards(items);
5558
}}
5659
/>
57-
<ul className="repo-cards">{cardsJSX}</ul>;
60+
<ul className="repo-cards">{cardsJSX}</ul>
5861
</main>
5962
</>
6063
);

0 commit comments

Comments
 (0)