Skip to content

Commit

Permalink
feat: add optional fetcher key to CartForm (#1792)
Browse files Browse the repository at this point in the history
* feat: add optional fetcher key to CartForm

* fix: formatting error

* Update .changeset/blue-garlics-obey.md

---------

Co-authored-by: Helen Lin <helen.lin@shopify.com>
  • Loading branch information
rmiller61 and wizardlyhel authored Mar 11, 2024
1 parent 90ee0f8 commit 351b3c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/blue-garlics-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/hydrogen': patch
---

add optional fetcher key to CartForm
8 changes: 7 additions & 1 deletion packages/hydrogen/src/cart/CartForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ type CartFormCommonProps = {
* The route to submit the form to. Defaults to the current route.
*/
route?: string;
/**
* Optional key to use for the fetcher.
* @see https://remix.run/hooks/use-fetcher#key
*/
fetcherKey?: string;
};

type CartActionInputProps =
Expand Down Expand Up @@ -217,8 +222,9 @@ export function CartForm({
action,
inputs,
route,
fetcherKey,
}: CartFormProps): JSX.Element {
const fetcher = useFetcher();
const fetcher = useFetcher({key: fetcherKey});

return (
<fetcher.Form action={route || ''} method="post">
Expand Down

0 comments on commit 351b3c1

Please sign in to comment.