/** * Created by zack on 2018/6/28. */ import { View, Text, StyleSheet, TouchableOpacity, Image, TextInput, Keyboard } from 'react-native' import React, {Component} from 'react' import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../../utils/DimensionsTools' export default class CountryCodeItem extends Component { constructor(props) { super(props) this.state = { name: props.name, phoneCode: props.phoneCode, } } componentWillReceiveProps(props) { this.setState({ name: props.name, phoneCode: props.phoneCode, }) } shouldComponentUpdate(nextProps) { if (nextProps.name !== this.state.name || nextProps.phoneCode !== this.state.phoneCode) { return true } return false } render() { return( { this.props.didSelectedItem() }} style={styles.View}> {this.state.name} {this.state.phoneCode} ) } } const styles = StyleSheet.create({ View: { width: ScreenDimensions.width, height:45, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, NameText: { fontSize: 16, color: '#333333', marginLeft: 15, }, PhoneCodeText: { fontSize: 16, color: '#333333', marginRight: 45, } })