我的应用程序仅工作正常,直到几天前,由于某种原因,应用程序卡在启动屏幕上。这适用于 Android 和 iOS 模拟器。
我尝试将所有依赖项更新到最新版本。我尝试重新安装所有软件包,但这也不起作用。我现在很困惑。
我目前正在 Expo Go 中运行该应用程序。
{
"name": "myapp",
"main": "expo-router/entry",
"version": "1.0.0",
"scripts": {
"start": "expo start",
"prebuild": "expo prebuild",
"doctor": "expo-doctor@latest",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"test": "jest --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/vector-icons": "^14.0.0",
"@gorhom/bottom-sheet": "^4",
"@react-native-community/datetimepicker": "7.6.1",
"@react-native-picker/picker": "2.6.1",
"@react-navigation/native": "^6.0.2",
"expo": "~50.0.15",
"expo-av": "^13.10.5",
"expo-font": "~11.10.3",
"expo-image-picker": "~14.7.1",
"expo-linking": "~6.2.2",
"expo-router": "~3.4.8",
"expo-splash-screen": "~0.26.4",
"expo-status-bar": "~1.11.1",
"expo-system-ui": "~2.9.3",
"expo-web-browser": "~12.8.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.73.6",
"react-native-gesture-handler": "~2.14.0",
"react-native-reanimated": "~3.6.2",
"react-native-safe-area-context": "4.8.2",
"react-native-screens": "~3.29.0",
"react-native-web": "~0.19.6"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.2.45",
"jest": "^29.2.1",
"jest-expo": "~50.0.4",
"react-test-renderer": "18.2.0",
"typescript": "^5.1.3"
},
"private": true
}
如果您要阻止启动画面自动隐藏,这可能会有所帮助。如果您使用回调函数,请确保“onLayout”属性仅位于 View 元素上。在旧版本的 SDK 上,您可以在其他一些元素上使用“onLayout”属性,但在新版本上,它不再起作用。我花了几天时间调试,直到发现 Stack 元素上的“onLayout”属性由于某种原因在较新版本的 SDK 上不起作用,但之前是可以的。我认为是我的错,是我在应用程序的上一版本中没有很好地遵循文档,所以后来出现了问题。我希望这可以帮助你。
我尝试了一切,但最终通过使用以下依赖项修复了它
"@expo/vector-icons": "^14.0.0",
"@react-native-community/datetimepicker": "8.0.1",
"@react-navigation/native": "^6.0.2",
"@react-native-picker/picker": "2.7.5",
"axios": "^1.7.2",
"expo": "~51.0.26",
"expo-camera": "~15.0.14",
"expo-constants": "~16.0.2",
"expo-image": "~1.12.13",
"expo-image-picker": "~15.0.7",
"expo-location": "~17.0.1",
"expo-notifications": "~0.28.15",
"expo-router": "~3.5.21",
"expo-secure-store": "~13.0.1",
"expo-splash-screen": "~0.27.5",
"firebase": "^10.12.2",
"jwt-decode": "^4.0.0",
"react": "18.2.0",
"react-native": "0.74.5",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-picker-select": "^9.1.3",
// 下面的内容修复了卡住的启动画面,我不知道具体是什么和为什么,但添加以下内容并继续您的生活,欢迎
"react-dom": "18.2.0",
"react-native-safe-area-context": "4.10.5",
"react-native-gesture-handler": "~2.16.1",
"react-native-reanimated": "~3.10.1",
"react-native-screens": "3.31.1"