Skip to content

Commit ebd2512

Browse files
perf(web): the primary cloud link hook compiles without manual memoization
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a702563 commit ebd2512

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

‎apps/web/src/cloud/primaryCloudLinkState.ts‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import * as Layer from "effect/Layer";
1111
import * as Option from "effect/Option";
1212
import { AsyncResult, Atom } from "effect/reactivity";
1313
import { HttpClient } from "effect/http";
14-
import { useCallback, useMemo } from "react";
1514

1615
import { usePrimaryEnvironment } from "../state/environments";
1716
import { runtime } from "../lib/runtime";
@@ -67,26 +66,23 @@ export function readCachedPrimaryCloudLinkState(target: CloudLinkTarget) {
6766
export function usePrimaryCloudLinkState() {
6867
const primary = usePrimaryEnvironment();
6968
const canReadRelay = useEnvironmentScope(primary?.environmentId ?? null, AuthRelayReadScope);
70-
const target = useMemo(
71-
() =>
72-
primary?.entry.target._tag === "PrimaryConnectionTarget"
73-
? {
74-
environmentId: primary.environmentId,
75-
label: primary.label,
76-
httpBaseUrl: primary.entry.target.httpBaseUrl,
77-
wsBaseUrl: primary.entry.target.wsBaseUrl,
78-
}
79-
: null,
80-
[primary],
81-
);
69+
const target =
70+
primary?.entry.target._tag === "PrimaryConnectionTarget"
71+
? {
72+
environmentId: primary.environmentId,
73+
label: primary.label,
74+
httpBaseUrl: primary.entry.target.httpBaseUrl,
75+
wsBaseUrl: primary.entry.target.wsBaseUrl,
76+
}
77+
: null;
8278
const atom =
8379
target && hasCloudPublicConfig() && canReadRelay
8480
? primaryCloudLinkStateAtom(targetKey(target))
8581
: EMPTY_PRIMARY_CLOUD_LINK_STATE_ATOM;
8682
const result = useAtomValue(atom);
87-
const refresh = useCallback(() => {
83+
const refresh = () => {
8884
refreshPrimaryCloudLinkState(target);
89-
}, [target]);
85+
};
9086
let error: string | null = null;
9187
if (result._tag === "Failure") {
9288
const cause = Cause.squash(result.cause);

0 commit comments

Comments
 (0)