Skip to content

Commit 745ca81

Browse files
perf(web): useAtomQueryRunner compiles without manual memoization (pingdotgg#20573)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 9434bfd commit 745ca81

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

‎apps/web/src/state/use-atom-query-runner.ts‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
type AtomCommandResult,
66
} from "@t3tools/client-runtime/state/runtime";
77
import { AsyncResult, type Atom } from "effect/reactivity";
8-
import { useCallback, useContext } from "react";
8+
import { useContext } from "react";
99

1010
export function useAtomQueryRunner<T, A, E>(
1111
family: (target: T) => Atom.Atom<AsyncResult.AsyncResult<A, E>>,
@@ -17,16 +17,13 @@ export function useAtomQueryRunner<T, A, E>(
1717
const reportDefect = typeof options === "string" ? true : (options?.reportDefect ?? true);
1818
const refresh = typeof options === "string" ? false : (options?.refresh ?? false);
1919

20-
return useCallback(
21-
(target: T) => {
22-
const atom = family(target);
23-
return executeAtomQuery(registry, atom, {
24-
label: explicitLabel ?? atom.label?.[0] ?? "atom query",
25-
reportFailure,
26-
reportDefect,
27-
refresh,
28-
});
29-
},
30-
[explicitLabel, family, registry, refresh, reportDefect, reportFailure],
31-
);
20+
return (target: T) => {
21+
const atom = family(target);
22+
return executeAtomQuery(registry, atom, {
23+
label: explicitLabel ?? atom.label?.[0] ?? "atom query",
24+
reportFailure,
25+
reportDefect,
26+
refresh,
27+
});
28+
};
3229
}

0 commit comments

Comments
 (0)