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
.
Like this:
regionSelectHandler(data){
return(
<View>
{
data.map(
Now, when you call regionSelectHandler
pass the array:
regionSelectHandler(multipleData1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.