Shopify / storefront-api-examples

Example custom storefront applications built on Shopify's Storefront API
https://help.shopify.com/api/storefront-api
MIT License
1.12k stars 329 forks source link

Solves #109 client variable-reference #130

Open enkelmedia opened 3 years ago

enkelmedia commented 3 years ago

Solves issue #109 by adding client varible.

swalkinshaw commented 3 years ago

Doesn't every usage of this.props.client need to be changed to just client now that the constant is defined?

swalkinshaw commented 3 years ago

I don't really understand how this fixes the issue though 🤔

The prop should exist: https://github.com/Shopify/storefront-api-examples/blob/ea24cff64152578a347695072cb41ba268c6662c/react-graphql-client/src/index.js#L18

Plus const client = this.props.client; implies it does exist

enkelmedia commented 3 years ago

I just started the Example site with npm run start, got the error, added this code and it worked. I haven’t spent a lot of time looking at why.

Might be more places where something similar is needed, might be a build-confit issue - I don’t know but this made the “add to cart” work which at least made the example useful.

Edit: I’m sure that the prop exists but one can’t just use the name of the prop, the code I’ve added creates a variable, it would probably work to just prepend this.props to the client variable usage.