-
Notifications
You must be signed in to change notification settings - Fork 378
Closed as not planned
Description
Gather feedback on whether devs think that using a singular data prop is better or worse than individual props with primitives when using Hydrogen-UI/storefront-kit and the Storefront API.
Context:
- Hydrogen-UI (soon to be renamed to storefront-kit) is a collection of React components that are built specifically for the Storefront API and its objects.
- It is not a goal of Hydrogen-UI to be a general-purpose component library; in other words, an
<Image/>component is intended to only work with Storefront API Image, a<ProductProvider/>component only works with a Storefront API Product, etc. - The majority of these components are "leaf nodes"; in other words, they are often the last rendered component in a React tree and do not have children.
Considerations:
- Which is the best DX?
- Are there performance implications by choosing one over the other?
- Do either create patterns in developer's code that we want to encourage or discourage?
- Could we enable both patterns, and if so, are there downsides?
Examples
data prop:
const product = getProductFromStorefrontApi();
return (
<Image data={product.image}/>
)Individual props:
const product = getProductFromStorefrontApi();
const {src, width, height, altText} = product.image;
return (
<Image src={src} width={width} height={height} alt={altText}/>
)(Feel free to add your thoughts to this issue)