<Icon.Button onPress={() => {this._change('male')}} name="ios-male">男</Icon.Button>
Writing like this will report an error. You need to write it in the following way and put it in return
<Icon.Button onPress={() => {() => {this._change('male')} }} name="ios-male">男</Icon.Button>
Does anyone know why?
This is not a function with parameters. You are directly executing a function with parameters.
Didn’t you realize that
_change
is executed without waiting for the click to start?The second way to write it is to wrap this method with a function, and execute this function when clicked.
Let’s take a look at the relevant basics.