Recreate Array to Prevent Same Memory Usage

Summary: Plugin is moved up as soon as it gets clicked because of the same array reference

Reviewed By: jknoxville

Differential Revision: D17285335

fbshipit-source-id: c4413844fe07a9aed77e4b0e9fb5f5e025d722ca
This commit is contained in:
Chaiwat Ekkaewnumchai
2019-09-10 10:43:09 -07:00
committed by Facebook Github Bot
parent bd35768590
commit faee603605

View File

@@ -239,8 +239,12 @@ const reducer = (state: State = INITAL_STATE, action: Actions): State => {
} }
const userPreferredApp = selectedApp || state.userPreferredApp; const userPreferredApp = selectedApp || state.userPreferredApp;
const LRUPlugins = // Need to recreate an array to make sure that it doesn't refer to the
(userPreferredApp && state.userLRUPlugins[userPreferredApp]) || []; // array that is showed in on the screen and the array that is kept for
// least recently used plugins reference
const LRUPlugins = [
...((userPreferredApp && state.userLRUPlugins[userPreferredApp]) || []),
];
const idxLRU = const idxLRU =
(selectedPlugin && LRUPlugins.indexOf(selectedPlugin)) || -1; (selectedPlugin && LRUPlugins.indexOf(selectedPlugin)) || -1;
if (idxLRU >= 0) { if (idxLRU >= 0) {