Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Commit 541cac7

Browse files
committed
Deprecated the old metafield parser and updated it to the new way
1 parent 9bff83c commit 541cac7

9 files changed

Lines changed: 125 additions & 1623 deletions

.changeset/wet-hounds-add.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,24 @@ The Storefront API changelog can be viewed [here](https://shopify.dev/api/releas
1414

1515
- The default Cart query no longer uses `compareAtPriceV2` and `priceV2`; use `compareAtPrice` and `price` instead. The `V2` fields will be removed in an upcoming version of the Storefront API.
1616
- The storefront client and ShopifyProvider now provide the `storeDomain` exactly as it is received; it's recommended that you pass the domain with the protocol and the fully-qualified domain name for your Storefront. For example: `https://hydrogen-test.myshopify.com`
17+
- `parseMetafield`'s implementation has been updated and vastly improved so that it is correctly parsing all the metafield types.
18+
19+
- The parsed metafield will now be found on the `parsedValue` property. For example:
20+
21+
```ts
22+
const metafield = parseMetafield(rawMetafield);
23+
24+
console.log(metafield.parsedValue);
25+
```
26+
27+
- Additionally, a new TypeScript type called `ParsedMetafields` is provided to help the `parseMetafield` function return the correct TypeScript types, by passing the type of metafield into the `ParsedMetafield` type. For example:
28+
29+
```ts
30+
const metafield = parseMetafield<ParsedMetafield['boolean']>(rawMetafield);
31+
32+
// parsedValue is a boolean
33+
if (metafield.parsedValue === true) {
34+
}
35+
```
36+
37+
- The `<Metafield/>` component has been removed; use `parseMetafield().parsedValue` to have control over what you want to render

packages/react/src/Metafield.stories.tsx

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)