描述
我有一个提交按钮,我使用这个函数来处理响应。当我使用Alert.alert()接口时,它会在没有任何警告的情况下自动关闭expo。
预期行为
我预计会在模拟器上看到弹出的警告,您执行了什么操作,您希望发生什么?
观察到的行为
世博会立即在电话或模拟器上关闭
环境
Expo CLI 3.13.1环境信息:系统: OS: macOS 10.15.3外壳: 5.7.1 - /bin/zsh二进制文件: Node: 12.14.0 - /usr/local/bin/node Yarn: 1.21.1 - /usr/local/bin/yarn npm: 6.13.7 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman IDEs: Android Studio: 3.5AI-191.8026.42.35.6010548 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild npmPackages: expo:^36.0.0 => 36.0.2 react: 16.9.0 => 16.9.0 react-native:https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz => 0.61.4 npmGlobalPackages: expo-cli: 3.13.1
Iphone11模拟器和expo物理版Iphone x
可重现的演示
import {Alert, Button, } from 'react-native';
const submitButton = () => {
Alert.alert('error', [{ text: 'Ok' }]);
}
//inside return func
<Button title="Submit" onPress={submitButton} />
发布于 2020-03-02 12:55:41
它崩溃了,因为你没有传递‘消息’。无论消息是否为空,都必须写入消息。
syntax of Alert :- static alert(title, message?, buttons?, options? type?)
yes. we knew that message Parameter is optional , but still you have to pass it when you use Alert.alert(), might be it is expo error .
1)解决方案
const submitButton = () => {
Alert.alert('error','', [{ text: 'Ok' }]);
}
2)解决方案
const submitButon = () => {
alert('error', [{ text: 'Ok' }]);
}
It will solved your problem
https://stackoverflow.com/questions/60476833
复制相似问题