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