The status of the component is updated but the view is not.

Code:

{(this.state.internet)? (
  <ListView contentContainerStyle={{backgroundColor: '#F78181'}}
    dataSource={this.state.dataSource}
    renderRow={ (rowData) => this.getVistaRadio(rowData,navigate)} />
  ) : (
  <View style={{alignItems: 'center',}}>
        <Text>Not Internet</Text>
  </View>)}

Code:

getVistaRadio(rowData,navigate){
return(
  <View style={this.state.seleccion ? getContenedorRadio(true) : getContenedorRadio(false)}>
  <Text>{rowData.title}</Text>
  </View>);}

Code:

function getContenedorRadio(presionado){
let color = '#000000'
if(presionado){color = '#FF0000';}
return{
    flex: 1,
    justifyContent: 'center',
    backgroundColor:'#FFFFFF',
    borderRadius:4,
    padding:5,
    borderWidth: 2,
    borderColor : color}}

If remove the condition of this.state.internet the code works but the code written above does not work (Does not change the view).

PD: In button call following function

active(){
  this.setState({
    seleccion:true
  });}

0 Answers