From e9441e3ff8ba2e5e07de6062a2a00d71fa6fe2ff Mon Sep 17 00:00:00 2001 From: Francisco Solla Date: Tue, 25 Aug 2026 12:38:02 -0300 Subject: [PATCH] =?UTF-8?q?react-audit(fam=C3=ADlia=203):=20mirror=20props?= =?UTF-8?q?=E2=86=92state=20via=20effect=20no=20badge=20=E2=80=94=20Campai?= =?UTF-8?q?gnNotificationBell.tsx:56=20reaplicava=20prop=20stale=20sobre?= =?UTF-8?q?=20o=20setUnreadCount(0)=20do=20open;=20sync=20no=20render=20co?= =?UTF-8?q?m=20guarda=20de=20open?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campaign/shell/CampaignNotificationBell.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/campaign/shell/CampaignNotificationBell.tsx b/src/components/campaign/shell/CampaignNotificationBell.tsx index 5d293e94..1b3f88bc 100644 --- a/src/components/campaign/shell/CampaignNotificationBell.tsx +++ b/src/components/campaign/shell/CampaignNotificationBell.tsx @@ -48,14 +48,20 @@ export const CampaignNotificationBell = ({ const isMobile = useIsMobile() const [open, setOpen] = useState(false) const [unreadCount, setUnreadCount] = useState(initialUnreadCount) + const [prevInitialUnreadCount, setPrevInitialUnreadCount] = useState(initialUnreadCount) const [items, setItems] = useState([]) const [isPending, startTransition] = useTransition() const [loadError, setLoadError] = useState(null) const nowMs = Date.now() - useEffect(() => { - setUnreadCount(initialUnreadCount) - }, [initialUnreadCount]) + // Prop sync during render (no effect): the badge is local state once the + // panel is open — opening marks everything as read — so a refresh racing the + // open must not resurrect the count. The old `useEffect` mirror could re-apply + // a stale prop over the local `setUnreadCount(0)`. + if (initialUnreadCount !== prevInitialUnreadCount) { + setPrevInitialUnreadCount(initialUnreadCount) + if (!open) setUnreadCount(initialUnreadCount) + } const loadPanel = useCallback(() => { startTransition(async () => {