简体   繁体   English

反应本地人如何在方法中使用道具

[英]react native how to use props in method

I am trying to use a method with props. 我正在尝试使用带有道具的方法。 I have method and I want to pass a prop inside a method. 我有方法,我想在方法内传递一个道具。 This is my method: 这是我的方法:

const multipleData1 = ['1 ', '2 ', '3 ', '4']
const multipleData2 = ['6 ', '7 ', '8 ', '9']
const multipleData3 = ['10 ', '11', '12 ', '13']

regionSelectHandler(){
     return(
     <View>
     {
      multipleData1.map(
         (interest) =>
           <SelectMultipleButton
             key={interest}
             buttonViewStyle={{
               borderRadius: 0,
               height: 40,
               width: 110,
             }}
             textStyle={{
               fontSize: 15,
             }}
           />
         )
      }
     </View>
   )}

Is there a way I could pass a prop in multipleData1.map so that I don't have to copy and paste the hole code each time I try to access to const multipleData2 and const multipleData3 . 有没有一种方法我可以通过一个道具multipleData1.map ,这样我就不必复制和每一次我尝试访问粘贴孔代码const multipleData2const multipleData3

Like this: 像这样:

regionSelectHandler(data){
     return(
     <View>
     {
      data.map(

Now, when you call regionSelectHandler pass the array: 现在,当您调用regionSelectHandler传递数组时:

regionSelectHandler(multipleData1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM