Skip to content

Commit dd23ea5

Browse files
author
Rizwan Zaheer
committed
creating albumDetail component & passing props with detail
1 parent 0fdbffe commit dd23ea5

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

App.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import Header from './src/components/Header';
1313
import AlbumList from './src/components/AlbumList';
1414

15+
1516
const instructions = Platform.select({
1617
ios: 'Press Cmd+R to reload,\n' +
1718
'Cmd+D or shake for dev menu',

src/components/AlbumDetail.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React, { Component } from 'react';
2+
import { View, Text } from 'react-native';
3+
4+
class AlbumDetail extends Component {
5+
render() {
6+
const { title } = this.props.album;
7+
return (
8+
<View>
9+
<Text>{title}</Text>
10+
</View>
11+
);
12+
}
13+
}
14+
export default AlbumDetail;

src/components/AlbumList.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Component } from 'react';
2-
import { Text, View } from 'react-native';
2+
import { View } from 'react-native';
33
import axios from 'axios';
4+
import AlbumDetail from './AlbumDetail';
45

56
class AlbumList extends Component {
67
state = {
@@ -15,10 +16,14 @@ class AlbumList extends Component {
1516
console.log('catch ', err);
1617
}));
1718
}
19+
renderAlbums() {
20+
return this.state.albums.map(album => <AlbumDetail key={album.title} album={album} />);
21+
}
22+
1823
render() {
1924
return (
2025
<View>
21-
<Text> Album List </Text>
26+
{this.renderAlbums()}
2227
</View>
2328
);
2429
}

0 commit comments

Comments
 (0)