basir / react-shopping-cart

React Redux Tutorial - Build ECommerce Shopping Cart In 5 Hours
https://react-shopping-cart-final.herokuapp.com/
212 stars 202 forks source link

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

Open RITESHKUMAR10 opened 4 years ago

RITESHKUMAR10 commented 4 years ago

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)

amabirbd commented 4 years ago

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

amabirbd commented 4 years ago

ok, i solved the problem.

yaprakbulut commented 4 years ago

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

amabirbd commented 4 years ago

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

yaprakbulut commented 4 years ago

@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.

amabirbd commented 4 years ago

@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 commented 4 years ago

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

ebbie commented 4 years ago

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 commented 4 years ago

@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

amabirbd commented 4 years ago

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

yaprakbulut commented 4 years ago

@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 :)

RITESHKUMAR10 commented 4 years ago

Thank you so much,its working.

On Wed, Sep 2, 2020, 12:42 Yaprak BULUT notifications@github.com 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 .

ebbie commented 4 years ago

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

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