[DOM] Add unstable_batchedUpdates to server-rendering-stub (#27028)
`unstable_batchedUpdates` shouldn't really be called on the server but the semantics are clear enough and we can provide a trivial implementation that calls the provided callback so we are adding it to the server-rendering-stub. This means we will also keep it around when we make the top level react-dom exports match the server-rendering-stub in the next major
Josh Story committed
Jun 30, 2023 at 11:19 UTC
1fdacbefd641d0ac1c97b159760eb03768771049
3 files changed
+11
-1
packages/react-dom/server-rendering-stub.js
+1
@@ -23,4 +23,5 @@ export {
23
preload,
24
preinit,
25
experimental_useFormStatus,
26
+ unstable_batchedUpdates,
27
} from './src/server/ReactDOMServerRenderingStub';
packages/react-dom/src/__tests__/react-dom-server-rendering-stub-test.js
-1
@@ -33,7 +33,6 @@ describe('react-dom-server-rendering-stub', () => {
33
expect(ReactDOM.hydrate).toBe(undefined);
34
expect(ReactDOM.render).toBe(undefined);
35
expect(ReactDOM.unmountComponentAtNode).toBe(undefined);
36
- expect(ReactDOM.unstable_batchedUpdates).toBe(undefined);
36
expect(ReactDOM.unstable_createEventHandle).toBe(undefined);
37
expect(ReactDOM.unstable_renderSubtreeIntoContainer).toBe(undefined);
38
expect(ReactDOM.unstable_runWithPriority).toBe(undefined);
packages/react-dom/src/server/ReactDOMServerRenderingStub.js
+10
@@ -31,3 +31,13 @@ export function flushSync() {
31
' to not call flushSync no the server.',
32
);
33
}
34
+
35
+// on the server we just call the callback because there is
36
+// not update mechanism. Really this should not be called on the
37
+// server but since the semantics are generally clear enough we
38
+// can provide this trivial implementation.
39
+function batchedUpdates<A, R>(fn: A => R, a: A): R {
40
+ return fn(a);
41
+}
42
+
43
+export {batchedUpdates as unstable_batchedUpdates};