当前位置: 首页 > article >正文

Hermes engine on React Native 0.72.5,function无法toString转成字符串

问题描述

Hermes engine on React Native 0.72.5,function无法toString转成字符串

环境

npm@6.14.18
node@16.17.1

项目依赖

"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.72.5",
"react-native-gesture-handler": "2.14.1",
"react-native-root-siblings": "3.2.3",
"react-native-safe-area-view": "0.14.101",
"react-navigation": "3.11.1",
"react-art": "^18.2.0",
"react-native-web": "0.9.9",
"react-native-web-webview": "^0.2.8",
"react-navigation-hooks": "^1.0.0-alpha.2",
"@babel/core": "^7.13.10",
"@babel/eslint-parser": "^7.18.9",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-object-rest-spread": "^7.14.5",
"@babel/plugin-transform-runtime": "^7.16.4",
"@babel/preset-env": "^7.16.4",
"@babel/preset-flow": "^7.16.0",
"@babel/preset-react": "^7.16.0",
"@babel/runtime": "^7.16.3",
"@react-native/eslint-config": "^0.72.2",
"@react-native/metro-config": "^0.72.11",
"@types/node": "^14.18.36",
"@types/react": "^18.0.18",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"babel-loader": "^8.2.3",
"babel-plugin-module-resolver": "^4.1.0",
"babel-plugin-show-source": "^0.2.1",
"@types/react-native": "^0.60.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.3",
"babel-jest": "23.6.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-react-native-web": "0.9.9",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.10",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-runtime": "^6.26.0",

解决方案

  1. 引入插件 babel-plugin-show-source
    插件地址:babel-plugin-show-source
  2. 配置项
// babel.config.js
module.exports = {
  plugins: [
    'babel-plugin-show-source',
    // or with options
    [
      'babel-plugin-show-source',
      {
        removeDirective: true,
      },
    ],
  ],
};
  1. 在function的第一行加入 show source 即可解决问题。【function里不允许有注释内容
  2. 特殊情况
    若按以上操作不起作用,请在配置里单独设置指令,如
plugins: [
    [
      'babel-plugin-show-source',
      {
        directive: 'show source please',
        // change the directive when in use with hermes
      },
    ],
  ],

再在function的第一行加入 show source please ,即可解决问题。

参考Issues

https://github.com/facebook/hermes/issues/612
https://github.com/supervons/react-native-echarts-pro/issues/35


http://www.kler.cn/a/429370.html

相关文章:

  • 处理 SQL Server 中的表锁问题
  • HunyuanVideo 文生视频模型实践
  • js-判断一个object(对象)是否为空
  • react中hooks之useEffect 用法总结
  • ASP.NET Core - IStartupFilter 与 IHostingStartup
  • 探索 Vue.js 组件开发的新边界:动态表单生成技术
  • VUE3学习二
  • 使用docker让项目持续开发和部署
  • 【NLP 12、深度学习15条调参经验】
  • 【Golang】Go语言编程思想(四):测试与性能调优
  • 字符串知识
  • C语言专题之结构体的使用
  • 锐捷网络设备常用命令(交换机、路由器)
  • “掌握AWD:解密全轮驱动的终极性能“
  • amazon亚马逊滑动识别验证码
  • Python Web 开发:FastAPI 依赖注入与中间件应用
  • PHP期末复习(通过30道填空题梳理知识点)
  • 十六,Spring Boot 整合 Druid 以及使用 Druid 监控功能
  • 零基础微信小程序开发——WXML 模板语法之事件绑定(保姆级教程+超详细)
  • 嵌入式驱动开发详解4(内核定时器)
  • sessionStorage对象--JSON数组--使用花括号{}直接定义对象--丝滑小连招:----客户端缓存之一
  • 【linux】shell(32)-循环控制
  • C#导出数据库到Excel文件(.NET)
  • Mac Open in terminal 总是打开vscode
  • 计算机网络-IPSec VPN工作原理
  • ejb组件(rmi) webservice平台(xml)