Skip to content
TypeScript

perf(web): the primary session state hook compiles without manual memoization (#20581)

Julius Marminge6f68d6d7d500
diff --git a/apps/web/src/environments/primary/sessionState.ts b/apps/web/src/environments/primary/sessionState.ts
index e40a75b4d47..34dc68b2f3c 100644
--- a/apps/web/src/environments/primary/sessionState.ts
+++ b/apps/web/src/environments/primary/sessionState.ts
@@ -3,7 +3,6 @@ import * as Cause from "effect/Cause";
import * as Effect from "effect/Effect";
import * as Option from "effect/Option";
import { AsyncResult, Atom } from "effect/reactivity";
-import { useCallback } from "react";
import { isLocalEnvironmentDisabled } from "../../localEnvironment";
import { appAtomRegistry } from "../../rpc/atomRegistry";
@@ -25,9 +24,6 @@ function refreshPrimarySessionState(): void {
export function usePrimarySessionState() {
const result = useAtomValue(primarySessionStateAtom);
- const refresh = useCallback(() => {
- refreshPrimarySessionState();
- }, []);
let error: string | null = null;
if (result._tag === "Failure") {
const cause = Cause.squash(result.cause);
@@ -37,6 +33,6 @@ export function usePrimarySessionState() {
data: Option.getOrNull(AsyncResult.value(result)),
error,
isPending: result.waiting,
- refresh,
+ refresh: refreshPrimarySessionState,
};
}