Skip to content

Commit

Permalink
Some exports are missing from the react-dom server-rendering-stub
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Jun 30, 2023
1 parent 7f362de commit 51cab22
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/react-dom/server-rendering-stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export {
preload,
preinit,
experimental_useFormStatus,
unstable_batchedUpdates,
} from './src/server/ReactDOMServerRenderingStub';
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe('react-dom-server-rendering-stub', () => {
expect(ReactDOM.hydrate).toBe(undefined);
expect(ReactDOM.render).toBe(undefined);
expect(ReactDOM.unmountComponentAtNode).toBe(undefined);
expect(ReactDOM.unstable_batchedUpdates).toBe(undefined);
expect(ReactDOM.unstable_createEventHandle).toBe(undefined);
expect(ReactDOM.unstable_renderSubtreeIntoContainer).toBe(undefined);
expect(ReactDOM.unstable_runWithPriority).toBe(undefined);
Expand Down
10 changes: 10 additions & 0 deletions packages/react-dom/src/server/ReactDOMServerRenderingStub.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ export function flushSync() {
' to not call flushSync no the server.',
);
}

// on the server we just call the callback because there is
// not update mechanism. Really this should not be called on the
// server but since the semantics are generally clear enough we
// can provide this trivial implementation.
function batchedUpdates<A, R>(fn: A => R, a: A): R {
return fn(a);
}

export {batchedUpdates as unstable_batchedUpdates};

0 comments on commit 51cab22

Please sign in to comment.