Code Monkey home page Code Monkey logo

Comments (8)

Zkirvalidze avatar Zkirvalidze commented on May 31, 2024 1

You just need to return item , in this particular part of onAdd function. as shown below

if (checkProductInCart) {
const updatedCartItems = cartItems.map((item) => {
if (item._id === product._id)
return {
...item,
quantity: item.quantity + quantity,
};
{
return item;
}
});

from ecommerce_sanity_stripe.

Bitrate2001 avatar Bitrate2001 commented on May 31, 2024

I found the same issue, can someone provide the fix for this error ?

from ecommerce_sanity_stripe.

Awaisp-irfan avatar Awaisp-irfan commented on May 31, 2024

@adrianhajdin, hey man could you look at this issue for us

from ecommerce_sanity_stripe.

F00r3y3s avatar F00r3y3s commented on May 31, 2024

The fixes for these issues are already provided in the issue section, the only thing I couldn't find is how to reset the quantity back to 1 once we move on to another product

product A = quantity 4

when click on another product

the quantity is still 4 and doesn't revert back to it's initial state which is "1"

from ecommerce_sanity_stripe.

Awaisp-irfan avatar Awaisp-irfan commented on May 31, 2024

hi Foor3y3s ,
Thanks for your help,
Could you tell me which issue it was

from ecommerce_sanity_stripe.

RobertoBenedit avatar RobertoBenedit commented on May 31, 2024

The error "Property does not exist on type 'never'" occurs when we try to access a property on a value of type never or when TypeScript gets confused when analyzing our code. To solve the error, use square brackets to access the property. e.g.

const onAdd = (product, quantity) => {
const checkProductInCart = cartItems.find((item) => item['_id'] === product._id);

In short, do obj['myProperty'], instead of obj.myProperty.

from ecommerce_sanity_stripe.

shivam-jha2712 avatar shivam-jha2712 commented on May 31, 2024

I am also facing a similar kind of error: if any of you could help me with this I am putting the video link https://www.loom.com/share/701a8b0c08144b34b4876296aa9a0a0c

from ecommerce_sanity_stripe.

bluevoxInc avatar bluevoxInc commented on May 31, 2024

You just need to return item , in this particular part of onAdd function. as shown below

if (checkProductInCart) { const updatedCartItems = cartItems.map((item) => { if (item._id === product._id) return { ...item, quantity: item.quantity + quantity, }; { return item; } });

This worked for me, thanks!

from ecommerce_sanity_stripe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.