Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the raw product returned from the Storefront API to also return from useProduct #735

Merged
merged 5 commits into from
Mar 31, 2023

Conversation

blittle
Copy link
Contributor

@blittle blittle commented Mar 29, 2023

At the moment useProduct() does not return the actual product from the Storefront API. Instead it only returns variants and product options. So if the developer wants any of the root product properties, they instead have to manually drill those props, or setup their own provider. This change makes the entire raw product from the Storefront API available:

function SomeComponent() {
  const {product} = useProduct();

  return (
    <div>
      <h2>{product.title}</h2>
      <h3>{product.description}</h3>
    </div>
  );
}

Resolves #689

@blittle blittle requested a review from frehner March 29, 2023 14:37
Comment on lines -188 to -189
product.sellingPlanGroups,
product.variants,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that this won't be a problem, changing the memo dependency array. I'd think if the product changes, so would these arrays. Also if these arrays change, so would the wrapping product.

@frehner
Copy link
Contributor

frehner commented Mar 29, 2023

Looks good to me so far. Would love to close #632 as part of this as well if we can! ❤️

packages/hydrogen-react/src/useProduct.doc.ts Outdated Show resolved Hide resolved
packages/hydrogen-react/src/useProduct.doc.ts Outdated Show resolved Hide resolved
packages/hydrogen-react/src/useProduct.example.jsx Outdated Show resolved Hide resolved
Copy link
Contributor

@frehner frehner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useProduct() in Hydrogen React does not include product title
2 participants