react-shopping-cart icon indicating copy to clipboard operation
react-shopping-cart copied to clipboard

React Tutorial - Part 13 - Shopping Cart By React & Redux | Add Redux To Cart

Open RITESHKUMAR10 opened this issue 4 years ago • 13 comments

Hii Sir, I am facing an error like getState is not a function in removeFromCart but in addToCart is working perfectly. Please resolve this error .

                                                                                                                                                  Tanking you...

Screenshot (252) Screenshot (254)

RITESHKUMAR10 avatar Aug 15 '20 05:08 RITESHKUMAR10

I am facing the same problem. @basir sir can you take a look at that issue?

amabirbd avatar Aug 25 '20 18:08 amabirbd

ok, i solved the problem.

amabirbd avatar Aug 26 '20 08:08 amabirbd

I have the same problem. How did you solve this ? @amabirbd

yaprakbulut avatar Aug 27 '20 07:08 yaprakbulut

@yaprakbulut most probably it's a typo . I forgot a "_" . I changed x._id !== product.id to x._id !== product._id

amabirbd avatar Aug 27 '20 12:08 amabirbd

@amabirbd No, this didn't solve. I checked the code but there is no wrong there. Also when my code keeps failing, I copied and pasted @basir ' s code, it still gives the same error.

yaprakbulut avatar Aug 28 '20 12:08 yaprakbulut

@amabirbd No, this didn't solve. I checked the code but there is no wrong there. Also when my code keeps failing, I copied and pasted @basir ' s code, it still gives the same error.

yes that happened to me too . check other files connected to that file like your cartReducer and store .

amabirbd avatar Aug 28 '20 13:08 amabirbd

@yaprakbulut and most importantly, don't forget to restart your pc ;)

amabirbd avatar Aug 28 '20 13:08 amabirbd

I got the same error too. Not sure how to solve it. @yaprakbulut Did you find the solution ? @amabirbd I checked my code and there seems to be no typo

ebbie avatar Sep 01 '20 06:09 ebbie

@RITESHKUMAR10 @amabirbd @yaprakbulut I think I found my solution too. In /components/Cart.js,

I missed adding {} around removeFromCart

Previously it was, export default connect((state) => ({ cartItems: state.cart.cartItems, }), removeFromCart )(Cart);

and I changed the above code to

export default connect((state) => ({ cartItems: state.cart.cartItems, }), {removeFromCart} // This is where I forgot to add the {} )(Cart);

@amabirbd I agree with you. Looks like only if we are missing something in the connected files, we are getting this error.

PS: If you are following udemy course videos and doing exactly as the professor says then it looks like the instructor forgot to add these curly braces {} while coding.

Hope this helps

ebbie avatar Sep 01 '20 06:09 ebbie

@ebbie that's probably it. Are you taking the udemy course?

amabirbd avatar Sep 01 '20 13:09 amabirbd

@RITESHKUMAR10 @amabirbd @yaprakbulut I think I found my solution too. In /components/Cart.js,

I missed adding {} around removeFromCart

Previously it was, export default connect((state) => ({ cartItems: state.cart.cartItems, }), removeFromCart )(Cart);

and I changed the above code to

export default connect((state) => ({ cartItems: state.cart.cartItems, }), {removeFromCart} // This is where I forgot to add the {} )(Cart);

@amabirbd I agree with you. Looks like only if we are missing something in the connected files, we are getting this error.

PS: If you are following udemy course videos and doing exactly as the professor says then it looks like the instructor forgot to add these curly braces {} while coding.

Hope this helps

@ebbie Thank you so much! It worked :)

yaprakbulut avatar Sep 02 '20 07:09 yaprakbulut

Thank you so much,its working.

On Wed, Sep 2, 2020, 12:42 Yaprak BULUT [email protected] wrote:

@RITESHKUMAR10 https://github.com/RITESHKUMAR10 @amabirbd https://github.com/amabirbd @yaprakbulut https://github.com/yaprakbulut I think I found my solution too. In /components/Cart.js,

I missed adding {} around removeFromCart

Previously it was, export default connect((state) => ({ cartItems: state.cart.cartItems, }), removeFromCart )(Cart);

and I changed the above code to

export default connect((state) => ({ cartItems: state.cart.cartItems, }), {removeFromCart} // This is where I forgot to add the {} )(Cart);

@amabirbd https://github.com/amabirbd I agree with you. Looks like only if we are missing something in the connected files, we are getting this error.

PS: If you are following udemy course videos and doing exactly as the professor says then it looks like the instructor forgot to add these curly braces {} while coding.

Hope this helps

@ebbie https://github.com/ebbie Thank you so much! It worked :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/basir/react-shopping-cart/issues/17#issuecomment-685401267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKLIWR5JS62T43RAWGCZDSDSDXV5TANCNFSM4QADDYHA .

RITESHKUMAR10 avatar Sep 02 '20 12:09 RITESHKUMAR10

@ebbie that's probably it. Are you taking the udemy course?

@amabirbd Yes, I completed it yesterday and the course was really good.

ebbie avatar Sep 02 '20 22:09 ebbie