<iclassName="bi bi-trash fill cart-item-delete-icon"onClick={()=>dispatch(removeFromCart(item.id))}
></i>
لكن تظهر لي رسالة الخطأ التالية:
react-dom.development.js:16227 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
at Object.throwInvalidHookError (react-dom.development.js:16227:1)
at useContext (react.development.js:1618:1)
at useReduxContext (useReduxContext.js:21:1)
at useStore (useStore.js:17:1)
at useDispatch (useDispatch.js:14:1)
at onClick (CartPage.jsx:43:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
at invokeGuardedCallback (react-dom.development.js:4277:1)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:1)
السؤال
محمود سعداوي2
السلام عليكم.
أريد حذف منتج معين.
قمت بكتابة الكود التالي:
removeFromCart(state,action){ state.cartItems = state.cartItems.filter(item => item.id !== action.payload) }
لكن تظهر لي رسالة الخطأ التالية:
شكرا على المساعدة
1 جواب على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.