Closed Carson-czl closed 3 years ago
在项目根目录添加scripts/react-scrollview-fix.js
const fs = require("fs");
try {
var rootDir = process.cwd();
var file = ${rootDir}/node_modules/react-native-spring-scrollview/SpringScrollView.js
;
var data = fs.readFileSync(file, "utf8");
var dataFix = 'react-native/Libraries/Components/TextInput/TextInputState';
if (data.indexOf(dataFix) !== -1) { throw "> Already fixed"; }
var result = data.replace( /react-native\/lib\/TextInputState/g, dataFix, ); fs.writeFileSync(file, result, "utf8");
} catch (error) { console.error(error); }
然后在package.json的scripts里面加上 "postinstall": "node scripts/react-scrollview-fix.js"
最后执行一次 npm run postinstall就行了
500是代码有问题或者RN问题吧
2021-03-10 11:50:46.977 31576-31704/com.haiyou.bd E/unknown:ReactNative: Unable to download JS bundle com.facebook.react.common.DebugServerException: The development server returned response error code: 500
我项目里的依赖
{ "name": "xxx", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android --main-activity=MainActivity", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "dependencies": { "@react-native-community/async-storage": "^1.12.1", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^5.9.9", "@react-native-community/viewpager": "^4.2.2", "@react-navigation/bottom-tabs": "^5.11.2", "@react-navigation/material-top-tabs": "^5.3.10", "@react-navigation/native": "^5.8.10", "@react-navigation/stack": "^5.12.8", "axios": "^0.21.1", "crypto-js": "^3.3.0", "react": "16.13.1", "react-native": "0.63.3", "react-native-gesture-handler": "^1.9.0", "react-native-idle-timer": "^2.1.6", "react-native-image-picker": "^3.1.4", "react-native-linear-gradient": "^2.5.6", "react-native-orientation-locker": "^1.2.0", "react-native-reanimated": "^1.13.2", "react-native-safe-area-context": "^3.1.9", "react-native-screens": "^2.15.0", "react-native-largelist-v3": "^3.0.14", "react-native-spring-scrollview": "^2.0.21", "react-native-tab-view": "^2.15.2", "react-native-update": "^5.10.0", "react-native-video": "^5.1.1", "react-redux": "^7.2.2", "redux": "^4.0.5", "redux-saga": "^1.1.3", "rn-fetch-blob": "^0.12.0" }, "devDependencies": { "@babel/core": "^7.8.4", "@babel/runtime": "^7.8.4", "@react-native-community/eslint-config": "^1.1.0", "@types/crypto-js": "^4.0.1", "@types/jest": "^25.2.3", "@types/react-native": "^0.63.2", "@types/react-native-video": "^5.0.3", "@types/react-redux": "^7.1.12", "@types/react-test-renderer": "^16.9.2", "@typescript-eslint/eslint-plugin": "^2.27.0", "@typescript-eslint/parser": "^2.27.0", "babel-jest": "^25.1.0", "eslint": "^6.5.1", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.59.0", "react-test-renderer": "16.13.1", "typescript": "^3.8.3" }, "jest": { "preset": "react-native", "moduleFileExtensions": [ "ts", "tsx", "js", "jsx", "json", "node" ] } }