无法在react-native-web应用中运行基于本机的组件

时间:2019-03-13 08:28:41

标签: native-base react-native-web

我正在使用React Native Web设置Web应用程序。我想对UI组件使用本机基础,但是无法在Web中使用它。我已遵循此说明https://github.com/GeekyAnts/NativeBase-KitchenSink/tree/web-support

自此有关图书馆的官方信息。

我的Web应用是使用以下命令创建的 纱线创建react-app test-web --typescript

然后添加 纱线添加react-native@0.55.4 react-native-web@0.10.0 react -art@16.8.2 纱线添加-D @ types / react-native @ 0.55.4

我的项目中没有babel配置,那么我该如何解决此问题 enter image description here

我的package.json文件

{
  "name": "test-web",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@babel/plugin-proposal-class-properties": "^7.3.4",
    "customize-cra": "^0.2.12",
    "native-base": "^2.12.1",
    "react": "^16.8.4",
    "react-app-rewired": "^2.1.1",
    "react-art": "16.8.2",
    "react-dom": "^16.8.4",
    "react-native": "0.55.4",
    "react-native-web": "0.10.0",
    "react-navigation": "^3.3.2",
    "react-scripts": "2.1.8"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "@types/react-native": "0.55.4"
  }
}

1 个答案:

答案 0 :(得分:0)

您是否将插件添加到了手机或应用程序目录中的babel.config.js文件中?

module.exports = {
     presets: ['module:metro-react-native-babel-preset'],
     plugins: ['@babel/plugin-proposal-class-properties']
};