以前运行良好,但在更新一些项目依赖项后突然出现此错误。它来自渲染的组件slate.js
对象(我不是渲染编辑器而是渲染文本)。我读到这个错误可以通过更新来解决babel-preset-react-native
,但我的已经是最新的了。我也导入过babel-polyfill
在入口文件中。
我在github上发现了很多这样的问题,但没有找到适合我的解决方案。
包.json
{
"name": "mobile",
"version": "0.0.1",
"dependencies": {
"antd-mobile": "^2.1.6",
"babel-polyfill": "^6.26.0",
"react": "16.2.0",
"react-native": "^0.49.0",
"react-native-navigation": "^1.1.375",
"slate": "^0.32.4"
},
"devDependencies": {
"babel-jest": "^22.2.2",
"babel-plugin-import": "^1.6.3",
"babel-preset-react-native": "^4.0.0",
"jest": "^22.2.2",
"react-native-dotenv": "^0.1.1",
"react-test-renderer": "^16.2.0"
},
"jest": {
"preset": "react-native"
}
}
{
"presets": ["react-native","react-native-dotenv"],
"plugins": [["import", { "libraryName": "antd-mobile" }]]
}
我在应用程序中使用打字稿,这是 tsconfig.json
{
"compilerOptions": {
"module": "es2015",
"target": "es2015",
"moduleResolution": "node",
"outDir": "./src",
"experimentalDecorators": true,
"noLib": false,
"declaration": false,
"emitDecoratorMetadata": true,
"lib": ["es6", "dom"],
"types": ["system","node"],
"jsx": "react"
},
"exclude": [
"node_modules"
]
}