diff --git a/package.json b/package.json index e305c2d..0d9b5b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "solid-swr", "description": "The beloved swr package ported over to solid", - "version": "4.0.8", + "version": "4.0.9", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/lib/index.ts b/src/lib/index.ts index 5359e96..85c2e70 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -8,14 +8,14 @@ import { onCleanup, useContext, } from "solid-js"; -import { createStore, reconcile, unwrap } from "solid-js/store"; +import { createStore, reconcile } from "solid-js/store"; import { SWRFallback } from "./context/fallback"; import useExponential from "./hooks/internal/useExponential"; import useInterval from "./hooks/internal/useInterval"; import useMutationOptions from "./hooks/internal/useMutationOptions"; import useWinEvent from "./hooks/internal/useWinEvent"; -import useMatchMutate from "./hooks/useMatchMutate"; +import useMatchMutate, { Payload as MatchMutatePayload } from "./hooks/useMatchMutate"; import useOptions from "./hooks/useOptions"; import tryCatch from "./utils/tryCatch"; import uFn from "./utils/uFn"; @@ -232,12 +232,10 @@ export default function useSWR( const mutationOptions = useMutationOptions(_mutationOptions); const matchMutate = useMatchMutate(); - const fresh = - payload instanceof Function - ? payload(structuredClone(unwrap(data.v))) - : payload; + const matchMutatePayload: MatchMutatePayload = + payload instanceof Function ? (_, res) => payload(res) : payload; - matchMutate(key => key === k, fresh, mutationOptions); + matchMutate(key => key === k, matchMutatePayload, mutationOptions); } );