Created
February 8, 2018 14:32
-
-
Save yogieputra8/17a948231246f8e695d66f9611a92882 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import { View, Text, Image, ActivityIndicator, TouchableOpacity } from 'react-native' | |
import { connect } from 'react-redux' | |
import { fetchReviewers } from '../actions' | |
class Reviewers extends Component { | |
componentDidMount(){ | |
this.props.dispatch(fetchReviewers()) | |
} | |
render(){ | |
return ( | |
<View style={{ flex: 1 }}> | |
<Text style={{ | |
marginLeft: 10, fontSize: 18 }}>Reviewers</Text> | |
{ | |
this.props.isFetching && | |
<ActivityIndicator size="large" /> | |
} | |
<View style={{ flexDirection: 'row', flexWrap: 'wrap', marginLeft: 10 }}> | |
{ | |
!this.props.isFetching && | |
this.props.reviewers.length > 0 && ( | |
this.props.reviewers.map((data, index) => ( | |
<TouchableOpacity | |
key={index} | |
onPress={() => console.log('index ke ', index)}> | |
<Image | |
style={{ | |
margin: 10, | |
width: 100, | |
height: 100, | |
borderRadius: 4, | |
resizeMode: 'contain' | |
}} | |
source={{ uri: data.avatar }} /> | |
</TouchableOpacity> | |
)) | |
) | |
} | |
</View> | |
</View> | |
) | |
} | |
} | |
const mapStateToProps = (state, ownProps) => { | |
console.log(state) | |
return { | |
reviewers: state.reviewers.items, | |
isfetching: state.reviewers.isFetching | |
} | |
} | |
export default connect(mapStateToProps) (Reviewers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment