Reputation: 117
The first image is about the error im getting and the second one is the API from which I need to show only vendor: store_name but while clicking on the update button it shows this error otherwise it remains okay and reloading manually only it works.
Unhandled Rejection (TypeError): Cannot read properties of undefined (reading 'store_address')
let cart_product_item = this.props.cart_product;
return (
{
cart_product_item && cart_product_item.length > 0 ?
cart_product_item[0].vendor.store_address : null
}
)
const mapStateToProps = (state) => {
return {
cart_product: state.homepageData.cart,
};
};
export default connect(mapStateToProps, {myCart})(Checkout);
Upvotes: -1
Views: 50
Reputation: 741
The question does not provide all the information required to answer, but here is probably what happens:
If the problem is indeed this, it can be overcome in many ways:
cart_product_item?.[0]?.vendor?.store_address || "Loading"
or similar.null
if the data is not there yet.Upvotes: 1