After adding checkout screen for my shopping cart, show invalid hook call error. As I thought I don't use any wrong function in my checkout screen. Here is my package.json file for dependencies. React and react-dom version is mismatch ??
"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" },
CodePudding user response:
I think there's probably an issue in how you are calling some hook (maybe some useState or useEffect hook).
Hooks cannot be called in a conditional way, so the workaround for this is just calling them at the top of functional components. You also can't call them inside if statements or loops.
here's a resource to check some rules you must follow when using react hooks
CodePudding user response:
It looks as though you're trying to call a React hook on the wrong place. Hooks can only be called from within a functional component or inside another hook. I think you should check where exactly is the error coming from and if you still can't figure it out then perhaps send some more information about the problem because with the resources u gave me there's not much I can do to help you.