为购物车添加结帐屏幕后,显示无效钩子调用错误。正如我所想,我没有在结帐屏幕上使用任何错误的功能。这是我的包裹。Json文件中的依赖项。React和React -dom版本不匹配??
"dependencies" {"@aws-amplify/datastore":"^ 3.12.1","@react-native-async-storage/async-storage":"^ 1.17.7","@react-native-community/netinfo":"^ 9.3.0","@react-navigation/bottom-tabs":"^ 6.3.1","@react-navigation/native":"^ 6.0.10","@react-navigation/stack":"^ 6.2.1","@reduxjs/toolkit":"^ 1.8.3","@stripe/stripe-react-native":"^ 0.14.0","amazon-cognito-identity-js"^ 5.2.9","aws-amplify"^ 4.3.26","aws-amplify-react-native"^ 6.0.5","country-list"^ 2.2.0","react"^ 18.0.0","react-dom"^ 18.2.0","react-native"0.69.0"react-native-gesture-handler"^ 2.5.0","react-native-material-kit"^ 0.6.0-beta.1","react-native-reanimated"^ 2.9.1","react-native-safe-area-context"^ 4.3.1","react-native-screens"^ 3.14.0","react-native-vector-icons"^ 9.2.0","react-redux"^ 8.0.2"},
错误我认为可能有一个问题在你如何调用一些钩子(也许一些useState或useEffect钩子)。
钩子不能以有条件的方式调用,所以解决这个问题的方法是在功能组件的顶部调用它们。你也不能在if语句或循环中调用它们。
这里有一个资源来检查一些你在使用react钩子时必须遵守的规则
看起来好像你试图在错误的地方调用React钩子。钩子只能从功能组件内部或在另一个钩子内部调用。我认为你应该检查一下错误到底是从哪里来的,如果你仍然不能弄清楚,那么也许可以发送一些关于这个问题的更多信息,因为根据你给我的资源,我不能帮你做太多。