PR REVIEWMissing useEffect Cleanup — Memory Leak on Unmount#519NotionLinear
00:00Junior~10 min
PULL REQUEST
Open#519 · 1 commit
Missing useEffect Cleanup — Memory Leak on Unmount
junior-dev-99 wants to mergefeature/notification-live-pollmain
JU
junior-dev-99
1 file changed · 4 hours ago
YOUR MISSION
A junior dev added a live-poll feature to the notifications panel. After navigating away, the browser console starts throwing "Can't perform a React state update on an unmounted component" and memory usage climbs. Spot the issue.
Junior~10 min
HINTS (0/3 used)
REVIEWING AS
SR
Senior Engineer
@ Notion · Backend Platform
src / components / NotificationsPanel.tsx+3 0
8
8
const [notifications, setNotifications] = useState([]);
9
9
10
10
useEffect(() => {
11
11
fetchNotifications().then(setNotifications);
12
+
setInterval(() => {
+
13
+
fetchNotifications().then(setNotifications);
+
14
+
}, 5000);
+
12
15
}, []);
13
16
14
17
return <NotificationList items={notifications} />;
Click any changed line (+/−) to flag an issue · or Approve if everything looks safe