batch for more efficient message processing
Summary: `unstablebatched_updates` should be used whenever a non-react originating event might affect multiple components, to make sure that React batches them optimally. Applied it to the most import events that handle incoming device events Reviewed By: nikoant Differential Revision: D25052937 fbshipit-source-id: b2c783fb9c43be371553db39969280f9d7c3e260
This commit is contained in:
committed by
Facebook GitHub Bot
parent
375a612dff
commit
2e5b52d247
24
desktop/flipper-plugin/src/state/batch.tsx
Normal file
24
desktop/flipper-plugin/src/state/batch.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {unstable_batchedUpdates} from 'react-dom';
|
||||
|
||||
export const batch = unstable_batchedUpdates;
|
||||
|
||||
export function batched<T extends Function>(fn: T): T;
|
||||
export function batched(fn: any) {
|
||||
return function (this: any) {
|
||||
let res: any;
|
||||
batch(() => {
|
||||
// eslint-disable-next-line
|
||||
res = fn.apply(this, arguments);
|
||||
});
|
||||
return res;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user