Skip to content

Commit 9eb2e10

Browse files
committed
Implement simple PR review fixes from Caleb
1 parent 83e0024 commit 9eb2e10

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/components/ui/coaching-sessions/coaching-notes/connection-status.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import { useEffect, useReducer } from "react";
22
import { Badge } from "@/components/ui/badge";
33
import { Spinner } from "@/components/ui/spinner";
44
import { useEditorCache } from "@/components/ui/coaching-sessions/editor-cache-context";
@@ -34,13 +34,23 @@ interface ConnectionStatusConfig {
3434
* - Offline: Provider lost connection or no collaboration provider available
3535
* - Error: Provider initialization or connection error
3636
*/
37-
export const ConnectionStatus: React.FC = () => {
37+
export const ConnectionStatus = () => {
3838
const { isReady, isLoading, error, collaborationProvider } = useEditorCache();
39-
// Force re-render mechanism to pick up provider.status changes (external non-React state)
40-
const [, forceUpdate] = React.useReducer(x => x + 1, 0);
39+
40+
/**
41+
* Force re-render mechanism for tracking external state changes.
42+
*
43+
* The collaboration provider's status property (provider.status) is not React state,
44+
* so changes to it don't automatically trigger re-renders. We use useReducer as a
45+
* "force update" function: calling forceUpdate() increments an internal counter,
46+
* which causes React to re-render this component and pick up the new provider.status value.
47+
*
48+
* This is a standard React pattern for syncing with external (non-React) state objects.
49+
*/
50+
const [, forceUpdate] = useReducer(x => x + 1, 0);
4151

4252
// Track provider status changes to trigger re-renders
43-
React.useEffect(() => {
53+
useEffect(() => {
4454
if (!collaborationProvider) {
4555
return;
4656
}

0 commit comments

Comments
 (0)