Use the client hash only in useEffect

This commit is contained in:
Tat Dat Duong
2025-06-27 19:59:21 +02:00
parent 9b7cc1c82e
commit b6655fe083
+3 -4
View File
@@ -321,11 +321,10 @@ function useThreadHistory<StateType extends Record<string, unknown>>(
) {
const [history, setHistory] = useState<ThreadState<StateType>[]>([]);
const clientHash = getClientConfigHash(client);
const clientRef = useRef(client);
clientRef.current = client;
const clientHash = getClientConfigHash(client);
const fetcher = useCallback(
(
threadId: string | undefined | null,
@@ -342,13 +341,13 @@ function useThreadHistory<StateType extends Record<string, unknown>>(
clearCallbackRef.current?.();
return Promise.resolve([]);
},
[clientHash],
[],
);
useEffect(() => {
if (submittingRef.current) return;
fetcher(threadId);
}, [fetcher, submittingRef, threadId]);
}, [fetcher, clientHash, submittingRef, threadId]);
return {
data: history,