在 Expo SDK36 RN 0.61.4 returns 中获取未定义
Fetch in Expo SDK36 RN 0.61.4 returns as undefined
我最初是使用此功能调整大小,然后在较早版本的 Expo 中上传图片,效果很好:
uploadImage = async (originalUri) => {
const { dispatchAvatar } = this.props;
const { uri } = await reduceImageAsync(originalUri);
const response = await fetch(uri);
const blob = await response.blob();
const photoData = { uri, blob };
dispatchAvatar(photoData);
};
然而,在 Expo SDK36 (RN 0.61.4) 中,当我尝试获取 uri 时,响应 returns 未定义。 uri 只是一个本地文件 (file:///),如果我查看 response.headers,我可以看到 "content-type": "image/jpeg",因此提取可以正确识别文件.
当我尝试记录响应时,我得到:
console.error: "There was a problem sending log messages to your development environment",
Error: value.hasOwnProperty is not a function. (In value.hasOwnProperty('tag')',
'value.hasOwnProperty' is undefined).
升级到更新版本的 Expo 和 React Native 会破坏这个吗?不适用于 iOS 设备或模拟器。
按照此处更新的示例进行操作,效果很好:
https://github.com/expo/examples/blob/master/with-firebase-storage-upload/App.js
我最初是使用此功能调整大小,然后在较早版本的 Expo 中上传图片,效果很好:
uploadImage = async (originalUri) => {
const { dispatchAvatar } = this.props;
const { uri } = await reduceImageAsync(originalUri);
const response = await fetch(uri);
const blob = await response.blob();
const photoData = { uri, blob };
dispatchAvatar(photoData);
};
然而,在 Expo SDK36 (RN 0.61.4) 中,当我尝试获取 uri 时,响应 returns 未定义。 uri 只是一个本地文件 (file:///),如果我查看 response.headers,我可以看到 "content-type": "image/jpeg",因此提取可以正确识别文件.
当我尝试记录响应时,我得到:
console.error: "There was a problem sending log messages to your development environment",
Error: value.hasOwnProperty is not a function. (In value.hasOwnProperty('tag')',
'value.hasOwnProperty' is undefined).
升级到更新版本的 Expo 和 React Native 会破坏这个吗?不适用于 iOS 设备或模拟器。
按照此处更新的示例进行操作,效果很好: https://github.com/expo/examples/blob/master/with-firebase-storage-upload/App.js