React Native+Expo Go运行报错:Property 'structuredClone'不存在
关于React Native + Expo Go下
structuredClone报错的问题 环境信息
- React Native版本:
0.72.6 - Expo版本:
~49.0.15 - TypeScript版本:
^5.1.3 - JS引擎:已在
app.json中配置Hermes
问题重现流程
- 执行
npm run android启动应用 - 终端按
s切换到Expo Go模式 - 通过扫码在安卓真机打开应用,或在Pixel 6(Android API 34)模拟器运行
- 进入使用
structuredClone的页面时,应用崩溃,报错Property 'structuredClone' doesn't exist
注:使用默认开发构建运行时一切正常
疑问点
- 如何选择具体的JS引擎版本?
- 开发模式与Expo Go运行有何差异,为何仅在Expo Go下出现该报错?
需求咨询
希望继续使用Hermes,请问:
- 能否为
structuredClone添加polyfill? - 使用
JSON.parse(JSON.stringify(myObject))这类替代方法是否可行?
附app.json配置代码
{ "expo": { "name": "my-app", "slug": "my-app", "jsEngine": "hermes", "version": "1.0.0", "orientation": "portrait", "icon": "./assets/icon.png", "userInterfaceStyle": "light", "splash": { "image": "./assets/splash.png", "resizeMode": "contain", "backgroundColor": "#ffffff" }, "assetBundlePatterns": ["**/*"], "ios": { "supportsTablet": true }, "android": { "adaptiveIcon": { "foregroundImage": "./assets/adaptive-icon.png", "backgroundColor": "#ffffff" }, "package": "com.myname.myapp" }, "web": { "favicon": "./assets/favicon.png" } } }
内容的提问来源于stack exchange,提问作者Cooty
相关产品推荐
相关产品推荐

