Skip to content
TypeScript

perf(web): useAtomQueryRunner compiles without manual memoization (#20573)

Julius Marminge745ca81b9d8a
diff --git a/apps/web/src/state/use-atom-query-runner.ts b/apps/web/src/state/use-atom-query-runner.ts
index d90caee210a..81b4140b227 100644
--- a/apps/web/src/state/use-atom-query-runner.ts
+++ b/apps/web/src/state/use-atom-query-runner.ts
@@ -5,7 +5,7 @@ import {
type AtomCommandResult,
} from "@t3tools/client-runtime/state/runtime";
import { AsyncResult, type Atom } from "effect/reactivity";
-import { useCallback, useContext } from "react";
+import { useContext } from "react";
export function useAtomQueryRunner<T, A, E>(
family: (target: T) => Atom.Atom<AsyncResult.AsyncResult<A, E>>,
@@ -17,16 +17,13 @@ export function useAtomQueryRunner<T, A, E>(
const reportDefect = typeof options === "string" ? true : (options?.reportDefect ?? true);
const refresh = typeof options === "string" ? false : (options?.refresh ?? false);
- return useCallback(
- (target: T) => {
- const atom = family(target);
- return executeAtomQuery(registry, atom, {
- label: explicitLabel ?? atom.label?.[0] ?? "atom query",
- reportFailure,
- reportDefect,
- refresh,
- });
- },
- [explicitLabel, family, registry, refresh, reportDefect, reportFailure],
- );
+ return (target: T) => {
+ const atom = family(target);
+ return executeAtomQuery(registry, atom, {
+ label: explicitLabel ?? atom.label?.[0] ?? "atom query",
+ reportFailure,
+ reportDefect,
+ refresh,
+ });
+ };
}