2
I have this button that should have a background-color depending on the state:
<TouchableOpacity onPress={this._onPressButtonMassa}>
<View style={[styles.button, this.props.hipertrofia === 'sim' ?
{ backgroundColor: 'black' } : { backgroundColor: 'white' }]}>
<Icon name="bicycle" size={50} color="#FAFAFA" />
<Text style={styles.buttonText}>Quero ganhar massa</Text>
</View>
</TouchableOpacity>
When I click on that button the state is changed:
_onPressButtonMassa = () => {
this.setState({ hipertrofia: 'sim' });
this.setState({ perdapeso: 'nao' });
};
But the button starts with the background-color white, and when the state is changed it does not render the button again, remaining white regardless of the value of this.props.hipertrofia
How can I render my button again so that it changes to the background-color
black when you click on it?