Skip to content

Commit b9bcba5

Browse files
committed
Include prefix in debug values
1 parent 5f3d37c commit b9bcba5

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/__test__/infinite.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,16 @@ describe("createInfiniteHook", () => {
104104
it("invokes debug value hook with path", () => {
105105
useInfinite("/pet/findByStatus", () => null);
106106

107-
expect(useDebugValue).toHaveBeenLastCalledWith("/pet/findByStatus");
107+
expect(useDebugValue).toHaveBeenLastCalledWith(
108+
"<unique-key> - /pet/findByStatus",
109+
);
108110

109111
useInfinite("/pet/findByTags", () => ({
110112
params: { query: { tags: ["tag1"] } },
111113
}));
112114

113-
expect(useDebugValue).toHaveBeenLastCalledWith("/pet/findByTags");
115+
expect(useDebugValue).toHaveBeenLastCalledWith(
116+
"<unique-key> - /pet/findByTags",
117+
);
114118
});
115119
});

src/__test__/query-base.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,14 @@ describe("configureBaseQueryHook", () => {
117117
it("invokes debug value hook with path", () => {
118118
useQuery("/pet/findByStatus");
119119

120-
expect(useDebugValue).toHaveBeenLastCalledWith("/pet/findByStatus");
120+
expect(useDebugValue).toHaveBeenLastCalledWith(
121+
"<unique-key> - /pet/findByStatus",
122+
);
121123

122124
useQuery("/pet/{petId}", { params: { path: { petId: 4 } } });
123125

124-
expect(useDebugValue).toHaveBeenLastCalledWith("/pet/{petId}");
126+
expect(useDebugValue).toHaveBeenLastCalledWith(
127+
"<unique-key> - /pet/{petId}",
128+
);
125129
});
126130
});

src/infinite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function createInfiniteHook<
5050
type Key = [Prefix, Path, Init | undefined] | null;
5151
type KeyLoader = SWRInfiniteKeyLoader<Data, Key>;
5252

53-
useDebugValue(path);
53+
useDebugValue(`${prefix} - ${path as string}`);
5454

5555
const fetcher: SWRInfiniteFetcher<Data, KeyLoader> = useCallback(
5656
async ([_, path, init]) => {

src/query-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function configureBaseQueryHook(useHook: SWRHook) {
3030
? [(Init | null)?, Config?]
3131
: [Init | null, Config?]
3232
) {
33-
useDebugValue(path);
33+
useDebugValue(`${prefix} - ${path as string}`);
3434

3535
const key = useMemo(
3636
() => (init !== null ? ([prefix, path, init] as const) : null),

0 commit comments

Comments
 (0)