0
我試圖設置onPress來調用action
來分派圖標,具體取決於Redux中的狀態。根據狀態設置圖標onPress
<MaterialIcons
name="arrow-upward" size={30} style={mystyles1.myIcon}
onPress = this.props.style.name === 'styleNormal' ?
{() => this.props.changeStyleNew('styleNew')} :
{()=>this.props.changeStyleNormal('styleNormal')}
>
</MaterialIcons>
因此,如果this.props.style.name === 'styleNormal'
第一功能(changeStyleNew
)獲得通過,如果不是第二個(changeStyleNormal
)。我無法做到這一點。我收到錯誤:
TransformError C:/.../ExtComp02.js:
JSX value should be either an expression or a quoted JSX text (94:19)
我該如何做到這一點?非常感謝。