-
Notifications
You must be signed in to change notification settings - Fork 273
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
Think through data prop feedback #630
Comments
+1 for I like that it separates the concerns of data derived from the Storefront API vs props that we might supply to customize those components in our own app. |
If you add the Say we use imgix to get the images because of its performance improvements, does that mean we shouldn't use the Does the |
Also, how does getting product data from sources like Algolia affect this? The data structure could be different. I fear that the Headless sites will often have a mix of data sources. |
@beppek Correct, the
|
I created an internal poll, and the overwhelming majority of devs there preferred individual props. As of time of writing:
Based on the feedback received, it seems that we should move forward with individual props. It's something that I would like to have done for the |
Shopify/hydrogen-react#116 is a first pass at this. But also, the |
I was going to say that my knee-jerk reaction is to prefer individual props without really thinking about why. I understand the reasoning with the Image component and that the ProductProvider needs the data to match what SF API expects. I think it's easier for devs to reshape the product data (if it comes from another source) with individual props rather than a single Curious to hear if there were any arguments for or against |
That's a good point. And I think the flip-side is also true - it's easier for a developer to get an object from the Storefront API and pass it as a single So I guess it comes down to which experience we're optimizing for.
Yeah, that's a good concern to have. I'm not entirely sure that the component itself is going to help dictate how efficient the query is, though - it seems like the component may be the wrong layer for that (e.g. someone can still just pull out an Image's
Some highlights:
|
My gut reaction is to prefer individual props as it’s more explicit about what you’re passing (less magic ✨). But, to your last point, I see the value of a singular |
Discussed this with @elisenyang — we'd like to proceed with the plan to support both. We will keep the simple mental model of CSS classes vs. inline styles … In other words, This is a better solution than the spread pattern, as certain components may not want to have the value from data provided as the actual prop value … for example, As an example of how the above proposal would play out, I've updated the |
Looks great Ben! I like this approach and I think it'll give developers maximum flexibility. |
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:
<Image/>
component is intended to only work with Storefront API Image, a<ProductProvider/>
component only works with a Storefront API Product, etc.Considerations:
Examples
data
prop:Individual props:
(Feel free to add your thoughts to this issue)
The text was updated successfully, but these errors were encountered: