大家好,我需要在警报中加入一个组件(开关)。
export const secretAlert = (environment: object) => {
Alert.alert(
'Alert Title',
'My Alert Msg',
[
{
text: `Environment: ${Config.ENV}`,
},
{
text: 'Cancel',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel',
},
{ text: 'OK', onPress: () => console.log('OK Pressed') },
],
{ cancelable: false },
);
return (
<Text>test</Text>,
)
}
二次尝试
export const secretAlert = (environment: object) => {
Alert.alert(
'Alert Title',
'My Alert Msg',
[
{
text: `Environment: ${Config.ENV}`,
},
{
text: 'Cancel',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel',
switch: <ComponentHere>.
},
{ text: 'OK', onPress: () => console.log('OK Pressed') },
],
{ cancelable: false },
);
}
上面的代码是错误的,只是想让你知道我应该怎么做。有一种方法可以用默认的组件alert,或者我应该使用一些librarycustom组件?