Adresses an issue with menu mutation

Summary:
A Logview issue was raised for the following error:
Cannot assign to read only property '0' of object '[object Array]'.

Analysis:
Currently, the menuEntries are stored by reference in the reducer, and made read only to protect it against accidental writes. Tha's probably why the '0' assignment fails, and the fix is that the reducer should only get a defensive copy as config about the current menu entries to show.

Reviewed By: mweststrate

Differential Revision: D33454514

fbshipit-source-id: 2faf3036eb6ae4fbe9a8d0253fde27cf389d3e4c
This commit is contained in:
Lorenzo Blasa
2022-01-06 08:14:51 -08:00
committed by Facebook GitHub Bot
parent af8d54c6f1
commit e8dd7ffcc0

View File

@@ -473,7 +473,7 @@ export const selectPlugin = (payload: {
export const setMenuEntries = (menuEntries: NormalizedMenuEntry[]): Action => ({ export const setMenuEntries = (menuEntries: NormalizedMenuEntry[]): Action => ({
type: 'SET_MENU_ENTRIES', type: 'SET_MENU_ENTRIES',
payload: menuEntries, payload: menuEntries.slice(),
}); });
export const selectClient = (clientId: string): Action => ({ export const selectClient = (clientId: string): Action => ({