javascript - The onPress function in react-native cannot directly write functions with parameters
天蓬老师
天蓬老师 2017-06-10 09:49:13
0
1
849
 {this._change('male')}} name="ios-male">男

Writing like this will report an error. You need to write it in the following way and put it in return

 {() => {this._change('male')} }} name="ios-male">男

Does anyone know why?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all (1)
仅有的幸福

This is not a function with parameters. You are directly executing a function with parameters.
Didn’t you realize that_changeis 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.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!