Skip to content

Commit 4e932fa

Browse files
added react-3
1 parent 06bbd5a commit 4e932fa

File tree

3 files changed

+43
-18
lines changed

3 files changed

+43
-18
lines changed

src/App.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
import './App.css';
22
import Video from './components/Video';
3-
3+
import videos from './data/data'
44
function App() {
5-
let obj = {
6-
title: 'React JS tutorial',
7-
views: '999K',
8-
time: '1 year ago',
9-
channel: 'Coder Dost',
10-
};
5+
116
return (
127
<div className="App">
138
<div>Videos</div>
14-
<Video {...obj}></Video>
15-
<Video title="Node JS tutorial" views="100K" time="1 month ago"></Video>
16-
<Video
17-
title="Mongo DB tutorial"
18-
views="1M"
19-
time="1 month ago"
20-
channel="Coder Dost"
21-
></Video>
9+
{
10+
videos.map(video=><Video
11+
key={video.id}
12+
title={video.title}
13+
views={video.views}
14+
time={video.time}
15+
channel={video.channel}
16+
verified={video.verified}
17+
id={video.id}
18+
></Video>)
19+
}
20+
2221
</div>
2322
);
2423
}

src/components/Video.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import './Video.css';
22

3-
function Video({title,channel="Coder Dost",views,time}) {
3+
function Video({title,id,channel="Coder Dost",views,time,verified}) {
4+
5+
46
return (
57
<>
68
<div className='container'>
79
<div className="pic">
8-
<img src="http://placeimg.com/160/90/1" alt="Katherine Johnson" />
10+
<img src={`https://picsum.photos/id/${id}/160/90`} alt="Katherine Johnson" />
911
</div>
1012
<div className="title">{title}</div>
11-
<div className="channel">{channel}</div>
13+
<div className="channel">{channel} {verified && '✅'} </div>
1214
<div className="views">
1315
{views} views <span>.</span> {time}
1416
</div>

src/data/data.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const videos = [{
2+
id:1,
3+
title: 'React JS tutorial',
4+
views: '999K',
5+
time: '1 year ago',
6+
channel: 'Coder Dost',
7+
verified: true
8+
},{
9+
id:2,
10+
title: 'Node JS tutorial',
11+
views: '100K',
12+
time: '1 year ago',
13+
channel: 'Coder Dost',
14+
verified: false
15+
},
16+
{ id:3,
17+
title: 'React JS tutorial',
18+
views: '1M',
19+
time: '1 month ago',
20+
channel: 'Coder Dost',
21+
verified: true
22+
}];
23+
24+
export default videos;

0 commit comments

Comments
 (0)