Skip to content

Commit ea3b825

Browse files
rubennortemeta-codesync[bot]
authored andcommitted
Move unstable_batchedUpdates out of the renderer implementation API (facebook#56567)
Summary: Pull Request resolved: facebook#56567 Changelog: [internal] `unstable_batchedUpdates` was only ever defined in Paper, where it batched state updates triggered by an event handler. Some product code in apps using only Fabric imported it directly from Paper, where it was a no-op. After Paper was removed from React Native, the no-op was kept in `RendererImplementation` (and forwarded through `RendererProxy`) purely to preserve that compatibility — it has nothing to do with the Fabric renderer indirection that the rest of `RendererImplementation` is for. Drop it from the renderer implementation API and define the no-op directly at the `react-native` package boundary: - `index.js.flow` and `index.js` now define `unstable_batchedUpdates` inline (the public re-export already came from the package, so consumers using `import {unstable_batchedUpdates} from 'react-native'` are unaffected). - Remove the corresponding `unstable_batchedUpdates` definitions / re-exports from `RendererImplementation.js`, `RendererProxy.fb.js`, and the `jest-preset` mock. Reviewed By: javache Differential Revision: D101989236 fbshipit-source-id: 9d83668f0dbc108ec24371fba37ed7ce7b452978
1 parent 68a6be9 commit ea3b825

4 files changed

Lines changed: 8 additions & 13 deletions

File tree

packages/jest-preset/jest/mocks/RendererProxy.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const {
2323
isProfilingRenderer,
2424
renderElement,
2525
sendAccessibilityEvent,
26-
unstable_batchedUpdates,
2726
} = jest.requireActual<TRendererImplementation>(
2827
'react-native/Libraries/ReactNative/RendererImplementation',
2928
) as TRendererImplementation;
@@ -39,5 +38,4 @@ export {
3938
isProfilingRenderer,
4039
renderElement,
4140
sendAccessibilityEvent,
42-
unstable_batchedUpdates,
4341
};

packages/react-native/Libraries/ReactNative/RendererImplementation.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ export const getPublicInstanceFromInternalInstanceHandle =
5353
export const getPublicInstanceFromRootTag =
5454
ReactFabric.getPublicInstanceFromRootTag;
5555

56-
export function unstable_batchedUpdates<T>(
57-
fn: (bookkeeping: T) => void,
58-
bookkeeping: T,
59-
): void {
60-
fn(bookkeeping);
61-
}
62-
6356
export function isProfilingRenderer(): boolean {
6457
return Boolean(__DEV__);
6558
}

packages/react-native/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,8 @@ module.exports = {
362362
get UIManager() {
363363
return require('./Libraries/ReactNative/UIManager').default;
364364
},
365-
get unstable_batchedUpdates() {
366-
return require('./Libraries/ReactNative/RendererProxy')
367-
.unstable_batchedUpdates;
365+
unstable_batchedUpdates<T>(fn: (bookkeeping: T) => void, bookkeeping: T) {
366+
fn(bookkeeping);
368367
},
369368
get useAnimatedValue() {
370369
return require('./Libraries/Animated/useAnimatedValue').default;

packages/react-native/index.js.flow

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,12 @@ export * as Systrace from './Libraries/Performance/Systrace';
405405
export {default as ToastAndroid} from './Libraries/Components/ToastAndroid/ToastAndroid';
406406
export * as TurboModuleRegistry from './Libraries/TurboModule/TurboModuleRegistry';
407407
export {default as UIManager} from './Libraries/ReactNative/UIManager';
408-
export {unstable_batchedUpdates} from './Libraries/ReactNative/RendererProxy';
408+
export function unstable_batchedUpdates<T>(
409+
fn: (bookkeeping: T) => void,
410+
bookkeeping: T,
411+
): void {
412+
fn(bookkeeping);
413+
}
409414
export {default as useAnimatedValue} from './Libraries/Animated/useAnimatedValue';
410415
export {default as useAnimatedValueXY} from './Libraries/Animated/useAnimatedValueXY';
411416
export {default as useAnimatedColor} from './Libraries/Animated/useAnimatedColor';

0 commit comments

Comments
 (0)