File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ const cards = [
2626] ;
2727
2828function 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 ) ;
You can’t perform that action at this time.
0 commit comments