Guest User

Untitled

a guest
May 20th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. =============Parent Component===============
  2. import React, { Component } from 'react';
  3. import { ScrollView, View } from 'react-native';
  4. import EligiblePlayersItem from './EligiblePlayersItem';
  5.  
  6. class EligiblePlayers extends Component {
  7.  
  8. renderEligiblePlayers() {
  9. return this.props.playerList.map((player) =>
  10. <EligiblePlayersItem key={player.id} player={player} onPress={()=>console.log('hii')} />
  11. );
  12. }
  13.  
  14. render() {
  15. return (
  16. <View>
  17. <ScrollView horizontal>
  18. {this.renderEligiblePlayers()}
  19. </ScrollView>
  20. </View>
  21. );
  22. }
  23. }
  24.  
  25. =============Child Dumb Component==========
  26. import React from 'react';
  27. import { View, Text, TouchableOpacity } from 'react-native';
  28. import { Avatar } from 'react-native-elements';
  29.  
  30. const EligiblePlayersItem = (props) => {
  31. const { chancellor, executed, hitler, id, president, user } = props.player;
  32.  
  33. renderPlayers = () => {
  34. if (!president && !executed) {
  35. return (
  36. <TouchableOpacity style={styles.imageContainer} onPress={props.onPress.bind(this)} >
  37. <Avatar
  38. rounded
  39. xlarge
  40. resize="contain"
  41. source={{uri: user.avatar}}
  42. />
  43. <Text style={styles.textStyle} >
  44. {user.name}
  45. </Text>
  46. </TouchableOpacity>
  47. );
  48. }
  49. }
  50.  
  51. return (
  52. <View>
  53. {this.renderPlayers()}
  54. </View>
  55. );
  56. }
Add Comment
Please, Sign In to add comment