Fix active state reducer mutating existing state
Summary: This reducer was mutating existing state, which will throw since we freeze state to prevent exactly that. Fixed it by using a defensive copy. Note that `newActiveNotifications` doesn't suffer from the same as it is freshly allocated. See https://www.internalfb.com/intern/diffusion/FBS/browse/master/xplat/sonar/desktop/app/src/reducers/notifications.tsx?commit=29b592866b44&lines=160 Reviewed By: passy Differential Revision: D26399200 fbshipit-source-id: 5f9f22db3de48f4f595a028faf9e9ec547641cfb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a1194b27b7
commit
8d5f136a34
@@ -146,7 +146,7 @@ function activeNotificationsReducer(
|
|||||||
): State {
|
): State {
|
||||||
const {payload} = action;
|
const {payload} = action;
|
||||||
const newActiveNotifications = [];
|
const newActiveNotifications = [];
|
||||||
const newInactivatedNotifications = state.invalidatedNotifications;
|
const newInactivatedNotifications = state.invalidatedNotifications.slice();
|
||||||
|
|
||||||
const newIDs = new Set(payload.notifications.map((n: Notification) => n.id));
|
const newIDs = new Set(payload.notifications.map((n: Notification) => n.id));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user