frigate/web/src/components
Josh Hawkins 192aba901a
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
Replace react-tracked and react-use-websocket with useSyncExternalStore (#22386)
* refactor websockets to remove react-tracked

react 19 removed useReducer eager bailout, which broke react-tracked.

react-tracked works by wrapping state in a JavaScript Proxy. When a component reads state.someField, the proxy records that access. On the next state update, it compares only the fields each component actually touched and skips re-renders if those fields are unchanged. Under the hood, this relies on useReducer — and in React 18, useReducer had an "eager bail-out" that short-circuited rendering when the new state was === to the old state. React 19 removed that optimization, so every dispatch now schedules a render regardless, and the proxy comparison runs too late to prevent it.

useSyncExternalStore is a React primitive (added in 18, stable in 19) designed for exactly this pattern: subscribing to an external store:

useSyncExternalStore(
  subscribe,   // (listener) => unsubscribe — called when the store changes
  getSnapshot  // () => value — returns the current value for this subscriber
)

React calls getSnapshot during render and compares the result with Object.is. If the value is the same reference, the component bails out — no re-render. The key difference from react-tracked is that this bail-out is built into React's reconciler, not bolted on via proxy tricks and useReducer.

The per-topic subscription model makes this efficient. Instead of one global store where every subscriber has to check if their fields changed, each useWs("some/topic", ...) call subscribes only to that topic's listener set. When a message arrives for front_door/detect/state, only components subscribed to that exact topic get their listener fired → React calls their getSnapshot → Object.is compares the value → bail-out if unchanged. Components watching back_yard/detect/state are never even notified.

* remove react-tracked and react-use-websocket

* refactor usePolygonStates to use ws topic subscription

* fix TimeAgo refresh interval always returning 1s due to unit mismatch (seconds vs milliseconds)

older events now correctly refresh every minute/hour instead of every second

* simplify

* clean up

* don't resend onconnect

* clean up

* remove patch
2026-03-11 09:02:51 -05:00
..
audio Improve audio detection debugging (#19753) 2025-08-25 13:40:21 -05:00
auth Frontend fixes (#22309) 2026-03-07 06:43:00 -07:00
button UI tweaks (#20687) 2025-10-27 07:44:34 -05:00
camera Debug replay (#22212) 2026-03-04 10:07:34 -06:00
card Full UI configuration (#22151) 2026-02-27 08:55:36 -07:00
chat Add GenAI Backend Streaming and Chat (#22152) 2026-02-27 09:07:30 -07:00
classification Miscellaneous fixes (0.17 beta) (#21737) 2026-01-21 17:46:24 -07:00
config-form Frontend updates (#22327) 2026-03-08 12:27:53 -05:00
dynamic Replace react-tracked and react-use-websocket with useSyncExternalStore (#22386) 2026-03-11 09:02:51 -05:00
filter Add motion previews filter (#22347) 2026-03-09 14:14:13 -06:00
graph Fix storage graph (#19230) 2025-07-22 06:24:15 -06:00
icons feat: add i18n (translation/localization) (#16877) 2025-03-16 10:36:20 -05:00
indicators Update frontend to React 19 (#22275) 2026-03-05 07:42:38 -07:00
input Miscellaneous fixes (0.17 beta) (#21867) 2026-02-03 08:31:00 -06:00
menu Debug replay (#22212) 2026-03-04 10:07:34 -06:00
mobile Update frontend to React 19 (#22275) 2026-03-05 07:42:38 -07:00
navigation Miscellaneous Fixes (#20897) 2025-11-17 08:12:05 -06:00
overlay Recordings API and calendar UI performance improvements (#22352) 2026-03-09 17:22:01 -06:00
player Improve motion review and add motion search (#22253) 2026-03-05 17:53:48 -06:00
preview Improve review segmentation behavior (#19850) 2025-08-31 16:36:12 -05:00
settings Update frontend to React 19 (#22275) 2026-03-05 07:42:38 -07:00
timeline Improve annotation offset UX (#22310) 2026-03-07 07:50:00 -06:00
trigger Miscellaneous fixes (0.17 beta) (#21683) 2026-01-18 06:36:27 -07:00
ui Improve motion review and add motion search (#22253) 2026-03-05 17:53:48 -06:00
ws Debug replay (#22212) 2026-03-04 10:07:34 -06:00
Logo.tsx Use cn() for class names throughout (#11278) 2024-05-07 08:00:25 -06:00
Statusbar.tsx Miscellaneous Fixes (0.17 beta) (#21279) 2025-12-14 16:41:38 -07:00
Wrapper.tsx spacing on mobile landscape (#11397) 2024-05-16 10:51:57 -06:00