当我在 iOS 模拟器中重新加载我的 React Native 应用程序时,有时会出现以下错误屏幕。
有时根本不会发生,但有时一天会发生几次。
我在我的应用程序中使用 SignalR 客户端以及 Firebase Messaging。
我尝试将try catch block 放入我的所有应用程序,包括我使用 AsyncStorage 的地方,但这种情况仍在发生。
非常沮丧。
最佳答案
我的问题是我的组件中的图像来源。我已经告诉图像组件将 null 作为源传递,而服务器对图像的响应为空或 null。意思是:
<Image source={{uri: null}} style={styles.myImageStyle}/>
在 android 上没问题,但在 ios 上我遇到了这个错误。所以我将我的代码更改为以下,现在工作正常。
const imageUri = myImageUri!=null ? myImageUri : ""
<Image source={imageUri.length!=0?{uri: imageuri}: null} style={styles.myImageStyle}/>
关于ios - NSNull 类型的 JSON 值 '<null>' 无法转换为 NSString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53550292/