0
我在我的原生应用程序中使用此库(https://github.com/jacklam718/react-native-popup-dialog/blob/master/README.md)打开对话框。到目前为止,我跟着示例代码,他们已经和它很适合我:React Native调用一个函数在渲染中打开一个对话框
import PopupDialog from 'react-native-popup-dialog';
<View style={styles.container}>
<Button
text="Show Dialog"
onPress={() => {
this.popupDialog.show();
}}
/>
<PopupDialog
ref={(popupDialog) => { this.popupDialog = popupDialog; }}
>
<View>
<Text>Hello</Text>
</View>
</PopupDialog>
</View>
我的问题是打开的对话框时,我的屏幕首次加载。我试着做类似: {this.popupDialog.show()}和{()=> this.popupDialog.show()}和其他不起作用的变体。我希望能够打开对话框,不必点击按钮来获取onPress()函数来调用。任何人都可以在正确的地方引导我。
这工作谢谢! – ghost