Adding an item to the cart with an invalid merchandiseId is not popullating the error
field from the useCart
hook (hydrogen-react)
#2685
Unanswered
luispcosta
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone. I am trying to make it so that adding an item that does not exist to a cart throws an error (when calling
linesAdd
fromuseCart
).The
useCart
hook has a property callederror
which states:But if I try to render that
error
field after callinglinesAdd
, it is always undefined. And I know that this should fail because if I replicate this request using raw graphql queries to the shopify storefront API, here's the response I get back:However, looking at the query that hydrogen-react is doing when adding that same product with the invalid id, the response I get back is:
So my question is, how can we test that the
error
property is properly populated?For reference, the way I'm trying to print the value for this variable is:
Hydrogen react version:
@shopify/[email protected]
React version: 19
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions