Skip to content

useShopQuery equilavent in v2 docs (when in components) #594

Answered by juanpprieto
Husiar asked this question in Help
Discussion options

You must be logged in to vote

As @davidhousedev pointed out there are two options:

Option A.

Move the useShopQuery logic from the ImageModule to the loader (after your sanity query) and return the enriched variants with shopify variants. This will make the variants:

  • available at SSR if you await the Shopify sub-queries (recommended above the fold) or
  • available at CSR if you defer the shopify sub-queries (recommended if below the fold).

Option B.

Create a resource/api endpoint /app/routes/api/product-from-gid and implement a useFetcher.load in the ImageModule to fetch the product/variant based on the id from Sanity. This will be CSR only, so you could render a placeholder during loading.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Husiar
Comment options

@juanpprieto
Comment options

Answer selected by Husiar
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants