As @PitaJ pointed out, my issue was that StyleSheet.create
doesn’t return a plain javascript object, so the ...
operator can’t be applied.
I only want to add a solution to my original problem as well, that was to derive two different style objects from one basic one where only one property is added.
The docs for the StyleSheet
API indicate that the method flatten
can be used for this:
const amountBorderColor = this.state.isClaim ? 'green' : 'red'
const amountStyles = StyleSheet.flatten([styles.amountSection, {borderColor: amountBorderColor}])