Skip to content

Commit 4833881

Browse files
committed
Remove triggerRequest from the useEffect deps
1 parent eded210 commit 4833881

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

packages/react-hooks/src/hooks/useRealtime.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function useRealtimeRun<TTask extends AnyTask>(
108108
return () => {
109109
stop();
110110
};
111-
}, [runId, stop, options?.enabled, triggerRequest]);
111+
}, [runId, stop, options?.enabled]);
112112

113113
return { run, error, stop };
114114
}
@@ -233,7 +233,7 @@ export function useRealtimeRunWithStreams<
233233
return () => {
234234
stop();
235235
};
236-
}, [runId, stop, options?.enabled, triggerRequest]);
236+
}, [runId, stop, options?.enabled]);
237237

238238
return { run, streams: streams ?? initialStreamsFallback, error, stop };
239239
}
@@ -315,7 +315,7 @@ export function useRealtimeRunsWithTag<TTask extends AnyTask>(
315315
return () => {
316316
stop();
317317
};
318-
}, [tag, stop, options?.enabled, triggerRequest]);
318+
}, [tag, stop, options?.enabled]);
319319

320320
return { runs: runs ?? [], error, stop };
321321
}
@@ -400,7 +400,7 @@ export function useRealtimeBatch<TTask extends AnyTask>(
400400
return () => {
401401
stop();
402402
};
403-
}, [batchId, stop, options?.enabled, triggerRequest]);
403+
}, [batchId, stop, options?.enabled]);
404404

405405
return { runs: runs ?? [], error, stop };
406406
}

references/nextjs-realtime/src/app/batches/[id]/ClientBatchRunDetails.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
"use client";
22

33
import { Card, CardContent } from "@/components/ui/card";
4-
import { TriggerAuthContext, useRealtimeBatch } from "@trigger.dev/react-hooks";
54
import type { exampleTask } from "@/trigger/example";
5+
import { useRealtimeBatch } from "@trigger.dev/react-hooks";
66

77
import { Badge } from "@/components/ui/badge";
88
import {
99
Table,
1010
TableBody,
11-
TableCaption,
1211
TableCell,
1312
TableHead,
1413
TableHeader,
1514
TableRow,
1615
} from "@/components/ui/table";
17-
import { TaskRunShape, AnyRunShape } from "@trigger.dev/sdk/v3";
16+
import { AnyRunShape, TaskRunShape } from "@trigger.dev/sdk/v3";
1817
import { z } from "zod";
1918

2019
const MetadataSchema = z.object({
@@ -116,8 +115,17 @@ export function BackgroundRunsTable({ runs }: { runs: TaskRunShape<typeof exampl
116115
);
117116
}
118117

119-
function BatchRunTableWrapper({ batchId }: { batchId: string }) {
120-
const { runs, error } = useRealtimeBatch<typeof exampleTask>(batchId);
118+
function BatchRunTableWrapper({
119+
batchId,
120+
publicAccessToken,
121+
}: {
122+
batchId: string;
123+
publicAccessToken: string;
124+
}) {
125+
const { runs, error } = useRealtimeBatch<typeof exampleTask>(batchId, {
126+
accessToken: publicAccessToken,
127+
baseURL: process.env.NEXT_PUBLIC_TRIGGER_API_URL,
128+
});
121129

122130
console.log(runs);
123131

@@ -141,11 +149,5 @@ function BatchRunTableWrapper({ batchId }: { batchId: string }) {
141149
}
142150

143151
export default function ClientBatchRunDetails({ batchId, jwt }: { batchId: string; jwt: string }) {
144-
return (
145-
<TriggerAuthContext.Provider
146-
value={{ accessToken: jwt, baseURL: process.env.NEXT_PUBLIC_TRIGGER_API_URL }}
147-
>
148-
<BatchRunTableWrapper batchId={batchId} />
149-
</TriggerAuthContext.Provider>
150-
);
152+
return <BatchRunTableWrapper batchId={batchId} publicAccessToken={jwt} />;
151153
}

0 commit comments

Comments
 (0)