File tree Expand file tree Collapse file tree 4 files changed +41
-47
lines changed Expand file tree Collapse file tree 4 files changed +41
-47
lines changed Original file line number Diff line number Diff line change 6
6
< meta
7
7
name ="viewport "
8
8
content ="width=device-width, initial-scale=1.0 " />
9
- < title > Condition Rendering </ title >
9
+ < title > List </ title >
10
10
</ head >
11
11
< body >
12
12
< div id ="root "> </ div >
Original file line number Diff line number Diff line change 1
- # root {
2
- max-width : 1280px ;
3
- margin : 0 auto;
4
- padding : 2rem ;
5
- text-align : center;
6
- }
7
-
8
- .logo {
9
- height : 6em ;
10
- padding : 1.5em ;
11
- will-change : filter;
12
- transition : filter 300ms ;
13
- }
14
- .logo : hover {
15
- filter : drop-shadow (0 0 2em # 646cffaa );
16
- }
17
- .logo .react : hover {
18
- filter : drop-shadow (0 0 2em # 61dafbaa );
19
- }
20
-
21
- @keyframes logo-spin {
22
- from {
23
- transform : rotate (0deg );
24
- }
25
- to {
26
- transform : rotate (360deg );
27
- }
28
- }
29
-
30
- @media (prefers-reduced-motion : no-preference) {
31
- a : nth-of-type (2 ) .logo {
32
- animation : logo-spin infinite 20s linear;
33
- }
34
- }
35
-
36
- .card {
37
- padding : 2em ;
38
- }
39
-
40
- .read-the-docs {
41
- color : # 888 ;
42
- }
Original file line number Diff line number Diff line change 1
1
import List from './List' ;
2
2
3
3
function App ( ) {
4
+ const fruits = [
5
+ { id : 1 , name : 'Apple' , calories : 90 } ,
6
+ { id : 2 , name : 'banana' , calories : 45 } ,
7
+ { id : 3 , name : 'mango' , calories : 105 } ,
8
+ { id : 4 , name : 'coconut' , calories : 159 } ,
9
+ { id : 5 , name : 'pineapple' , calories : 37 } ,
10
+ ] ;
11
+ const vegatables = [
12
+ { id : 7 , name : 'Potatos' , calories : 105 } ,
13
+ { id : 8 , name : 'celery' , calories : 15 } ,
14
+ { id : 9 , name : 'carrots' , calories : 25 } ,
15
+ { id : 10 , name : 'corn' , calories : 63 } ,
16
+ { id : 11 , name : 'broccoli' , calories : 50 } ,
17
+ ] ;
4
18
return (
5
19
< >
6
- < List />
20
+ < List
21
+ items = { fruits }
22
+ category = "fruits"
23
+ />
24
+ < List
25
+ items = { vegatables }
26
+ category = "Vegatables"
27
+ />
7
28
</ >
8
29
) ;
9
30
}
Original file line number Diff line number Diff line change 1
- function List ( ) {
2
- const fruits = [ 'Apple' , 'banana' , 'coconut' , 'pineapple' ] ;
3
- return fruits ;
1
+ function List ( props ) {
2
+ const category = props . category ;
3
+ const itemList = props . items ;
4
+
5
+ const listItems = itemList . map ( ( item ) => (
6
+ < li key = { item . id } >
7
+ { item . id } )
8
+ { item . name } : { item . calories }
9
+ </ li >
10
+ ) ) ;
11
+ return (
12
+ < >
13
+ < h1 >
14
+ < b > { category } </ b >
15
+ </ h1 >
16
+ < ol > { listItems } </ ol >
17
+ </ >
18
+ ) ;
4
19
}
5
20
export default List ;
You can’t perform that action at this time.
0 commit comments