What I am trying to do is repeat a line item and the user will be able to change the quantity of each item on the line. for example
- Soda ............ - 1 +
- Breadsticks .. - 0 +
- etc... ............. - 3 +
so far I have been able to change value and log that the change is happening, but the value that is displayed does not change.
below is what I have so far
render() {
let pizzaSides = this.props.pizzaSidesArray.map((sidesObj) => {
sidesObj.count = 0;
decrement function to reduce the count of the item but not below 0.
decrement = () =>{
console.log('dec');
console.log(sidesObj);
if (sidesObj.count > 0) {
sidesObj.count--;
}
}
Increment adds when invoked
increment = () =>{
console.log('inc');
console.log(sidesObj);
sidesObj.count++;
}
return (
<View
key={sidesObj.name}
style={{
paddingTop: 10,
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between'}}>
<View style={{flex:1.5,flexDirection: 'row'}}>
<TouchableHighlight
onPress={ decrement}
style={{flex:1}}>
<Text> - </Text>
</TouchableHighlight>
although the touchable highlights log the change the text below does not change
<Text style={{flex:1}}>
{sidesObj.count}
</Text>
<TouchableHighlight
onPress={ increment}
style={{flex:1}}>
<Text> + </Text>
</TouchableHighlight>
</View>
</View>
);
});
return (
<View>
{pizzaSides}
</View>
)
}
}
Thanks for your help. :D