We are migrating our checkout.liquid and checkout.js to the new Checkout Extension. So far it’s mostly okay. I am trying to implement a date picker at two locations during checkout,
after the pickup options rendered, i.e.
purchase.checkout.pickup-location-list.render-after, and
However in the code when I try to use isLocationFormVisible as described in https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/apis/pickuplocationlistapi, it’s not allowing me to use this API. The Shopify React extension complains the line (68):
const {isLocationFormVisible} =
useApi<‘purchase.checkout.pickup-location-list.render-before’>();
Thanks for your help, and pointing out the syntax differences between jsx and typescript.
Since I am interested in PickupLocationListApi, I tried the following code:
import {
reactExtension,
BlockStack,
DateField,
useApi,
useApplyMetafieldsChange,
useMetafield,
useSubscription,
} from '@shopify/ui-extensions-react/checkout';
const deliveryDateRender = reactExtension(
'purchase.checkout.shipping-option-list.render-after', () =>
My VS code is now happy with the syntax, but I got the following runtime error:
The above error occurred in the <Extension> component:
at Extension ([https://vernon-sf-detroit-foot.trycloudflare.com/extensions/79ec14ec-f1d2-4dab-af1f-c0d07af30c7c/assets/delivery-date-picker.js:18481:26](https://vernon-sf-detroit-foot.trycloudflare.com/extensions/79ec14ec-f1d2-4dab-af1f-c0d07af30c7c/assets/delivery-date-picker.js:18481:26))
at ErrorBoundary ([https://vernon-sf-detroit-foot.trycloudflare.com/extensions/79ec14ec-f1d2-4dab-af1f-c0d07af30c7c/assets/delivery-date-picker.js:18346:7](https://vernon-sf-detroit-foot.trycloudflare.com/extensions/79ec14ec-f1d2-4dab-af1f-c0d07af30c7c/assets/delivery-date-picker.js:18346:7))
React will try to recreate this component tree from scratch using the error boundary you provided, ErrorBoundary.
....
Basically, it does not like the line of
const isPickupSelected = useSubscription(isLocationFormVisible);
If I comment out this line, the error goes away. But of course I don't get the value I would like to get. Do you have any idea what I am missing for using useSubscription properly?
Regards,
--Jude