24jieqi / react-native-xiaoshu

🌈 React Native UI library
https://24jieqi.github.io/react-native-xiaoshu
Apache License 2.0
188 stars 21 forks source link

启动工程的时候报错 #48

Closed geeker-cmc closed 6 months ago

geeker-cmc commented 6 months ago

invalid hook call.hooks can only be called inside of the body of a function component. package.json信息 { "name": "Test", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "react": "18.2.0", "react-native": "0.73.1", "@fruits-chain/react-native-xiaoshu": "0.3.18", "@react-native-async-storage/async-storage": "1.21.0", "@react-navigation/bottom-tabs": "^6.5.11", "@react-navigation/native": "6.1.9", "@react-navigation/native-stack": "6.9.17", "axios": "1.6.2", "rc-field-form": "1.41.0", "react-native-gesture-handler": "2.14.0", "react-native-root-siblings": "5.0.1", "react-native-root-toast": "3.5.1", "react-native-safe-area-context": "4.7.4", "react-native-screens": "3.27.0", "react-native-svg": "14.1.0", "zustand": "4.4.7" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/babel-preset": "^0.73.18", "@react-native/eslint-config": "^0.73.1", "@react-native/metro-config": "^0.73.2", "@react-native/typescript-config": "^0.73.1", "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", "eslint": "^8.19.0", "jest": "^29.6.3", "prettier": "2.8.8", "react-test-renderer": "18.2.0", "typescript": "5.0.4" }, "engines": { "node": ">=18" } } 使用Provider就直接报上面的错。 node版本20.10.0 系统mac m2

onlyling commented 6 months ago
npx react-native init Restore

## 删除 node_modules、lock 文件
## dependencies 按照上面的贴进去

yarn

cd ios
pod install

yarn ios

node -v v18.19.0

没有报错诶,Android 端没有试,JDK 版本和 React Native 0.73.x 要求的不一致。

image
geeker-cmc commented 6 months ago

嗯,使用yarn安装是正常的,使用npm安装就会报上述的问题,不知道是什么原因。

onlyling commented 6 months ago

嗯,使用yarn安装是正常的,使用npm安装就会报上述的问题,不知道是什么原因。

之前用 Expo 还原问题用 NPM 的方式也遇见过问题,当时是在 node_modules/@fruits-chain/react-native-xiaoshu 路径下安装了一份不同版本的 React Native,可能是一些依赖库对 React Native 版本锁定了,NPM 没有把依赖拍平。