大家好,有没有办法在react native中重定向到另一个带有警报的页面?

k10s72fa  于 2022-11-25  发布在  React
关注(0)|答案(1)|浏览(123)
const touchHandler = () => {
            if (true) {
                Alert.alert('Choose Action', 'Would you like to take a picture or select an existing one?', 
                [{ text: 'Select from gallery', 
                onPress: ()=> retrieveImageHandler }, {text: 'take a picture ' , onPress: ()=>{takeImageHandler}}]);
            
            }

OnPress按钮不会激发函数retrieveImageHandler和takeImageHandler

1szpjjfi

1szpjjfi1#

你可以把这个

onPress: ()=> retrieveImageHandler
onPress: ()=>{takeImageHandler}

onPress: ()=> retrieveImageHandler()
onPress: ()=>{takeImageHandler()}

因为当你用()=>调用函数时,你必须在函数名后面加上括号,比如()=> functionName()

相关问题