mirror of
https://github.com/coder/coder.git
synced 2026-09-23 05:43:53 +08:00
React's [Why You Might Not Need An Effect](https://react.dev/learn/you-might-not-need-an-effect) article describes several antipatterns and footguns you might encounter when working with useEffect, so I fed it to an agent and let it determine some low hanging fruit to fix: Replace useEffect+setState patterns with direct computations where the values are purely derived from props, state, or query data: - useWebpushNotifications: derive `enabled` inline from query data instead of setting it via useEffect - ProxyContext: replace `proxy` state + updateProxy callback + useEffect with a single useMemo over its three inputs - useSyncFormParameters: replace ref-sync useEffect with direct assignment during render - AgentsSidebar (LoadMoreSentinel): replace two ref-sync useEffects with direct assignments during render Co-authored by Coder Agent 🤖