如何向 React Native 应用添加 Web 功能
我的项目结构 我有一个可以运行的 React Native 应用,但我希望能够为 Web 构建。如能得到任何帮助,我将不胜感激。 下面是我的 package.json。
{
"name": "dotmac",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-solid-svg-icons": “^6.1.1”,
“@fortawesome/react-native-fontawesome”:“^0.2.7”,
“@js-joda/core”:“^5.2.0”,
“@react-native-async-storage/async-storage”:“^1.17.3”,
“@react-native-community/masked-view”:“^0.1.11”,
“@react-navigation/drawer”:“^6.4.1”,
“@react-navigation/native”:“^6.0.10”,
“@react-navigation/native-stack”:“^6.6.1”,
“@types/react-native-htmlview”:“^0.16.0”,
“axios”: “^0.26.1”,
“babel-plugin-module-resolver”:“^4.1.0”,
“currency.js”:“^2.0.4”,
“flutterwave-react-native”:“^1.0.2”,
“react”:“17.0.2”,
“react-hook-form”:“^7.29.0”,
“react-native”:“0.68.0”,
“react-native-animatable”:“^1.3.3”,
“react-native-gesture-handler”:“^2.3.2”,
“react-native-htmlview”:“^0.16.0”,
“react-native-onesignal”:“^4.4.0”,
“react-native-paystack-webview”: “^4.0.3”,
“react-native-raw-bottom-sheet”:“^2.2.0”,
“react-native-reanimated”:“^2.5.0”,
“react-native-safe-area-context”:“^4.2.4”,
“react-native-screens”:“^3.13.1”,
“react-native-svg”:“^12.3.0”,
“react-native-toast-message”:“^2.1.5”,
“react-native-webview”:“^11.18.1”,
“react-native-zohodesk-portal-sdk”:“^1.0.6”,
“react-native-zohosalesiq-mobilisten”: “^4.2.10”,
“twrnc”:“^3.0.2”
},
“devDependencies”:{
“@babel/core”:“^7.12.9”,
“@babel/runtime”:“^7.12.5”,
“@react-native-community/eslint-config”:“^2.0.0”,
“@types/jest”:“^26.0.23”,
“@types/react-native”:“^0.67.3”,
“@types/react-test-renderer”:“^17.0.1”,
“@typescript-eslint/eslint-plugin”:“^5.17.0”,
“@typescript-eslint/parser”: “^5.17.0”,
“babel-jest”:“^26.6.3”,
“eslint”:“^7.32.0”,
“jest”:“^26.6.3”,
“metro-react-native-babel-preset”:“^0.67.0”,
“react-test-renderer”:“17.0.2”,
“typescript”:“^4.4.4”
},
“resolutions”:{
“@types/react”:“^17”
},
“jest”:{
“preset”:“react-native”,
“moduleFileExtensions”: [
“ts”,
“tsx”,
“js”,
“jsx”,
“json”,
“node”
]
>
>
将 react-native-web 集成到现有项目中是一个比较困难的过程。您可以在此处遵循官方文档 ( https://necolas.github.io/react-native-web/docs/installation/ )