Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 5 additions & 7 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -232,12 +232,10 @@ export default function useSWR<Res = unknown, Err = unknown>(
const mutationOptions = useMutationOptions(_mutationOptions);
const matchMutate = useMatchMutate<Res>();

const fresh =
payload instanceof Function
? payload(structuredClone(unwrap(data.v)))
: payload;
const matchMutatePayload: MatchMutatePayload<Res> =
payload instanceof Function ? (_, res) => payload(res) : payload;

matchMutate(key => key === k, fresh, mutationOptions);
matchMutate(key => key === k, matchMutatePayload, mutationOptions);
}
);

Expand Down