Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =============Parent Component===============
- import React, { Component } from 'react';
- import { ScrollView, View } from 'react-native';
- import EligiblePlayersItem from './EligiblePlayersItem';
- class EligiblePlayers extends Component {
- renderEligiblePlayers() {
- return this.props.playerList.map((player) =>
- <EligiblePlayersItem key={player.id} player={player} onPress={()=>console.log('hii')} />
- );
- }
- render() {
- return (
- <View>
- <ScrollView horizontal>
- {this.renderEligiblePlayers()}
- </ScrollView>
- </View>
- );
- }
- }
- =============Child Dumb Component==========
- import React from 'react';
- import { View, Text, TouchableOpacity } from 'react-native';
- import { Avatar } from 'react-native-elements';
- const EligiblePlayersItem = (props) => {
- const { chancellor, executed, hitler, id, president, user } = props.player;
- renderPlayers = () => {
- if (!president && !executed) {
- return (
- <TouchableOpacity style={styles.imageContainer} onPress={props.onPress.bind(this)} >
- <Avatar
- rounded
- xlarge
- resize="contain"
- source={{uri: user.avatar}}
- />
- <Text style={styles.textStyle} >
- {user.name}
- </Text>
- </TouchableOpacity>
- );
- }
- }
- return (
- <View>
- {this.renderPlayers()}
- </View>
- );
- }
Add Comment
Please, Sign In to add comment