Skip to content

Think through data prop feedback #630

@frehner

Description

@frehner

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions