Skip to content

Commit

Permalink
[Float][Fizz] include preloadModule and preinitModule on `react-d…
Browse files Browse the repository at this point in the history
…om/server-rendering-stub` (facebook#27347)

When implementing `preloadModule` and `preinitModule` these methods were
not exposed on the server rendering stub when they should have been.
This PR corrects that omission.
  • Loading branch information
gnoff authored and AndyPengc12 committed Apr 15, 2024
1 parent 773d822 commit 33b824a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/react-dom/server-rendering-stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export {
prefetchDNS,
preconnect,
preload,
preloadModule,
preinit,
preinitModule,
experimental_useFormStatus,
experimental_useFormState,
unstable_batchedUpdates,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ describe('react-dom-server-rendering-stub', () => {
});

// @gate enableFloat
it('provides preload and preinit exports', async () => {
it('provides preload, preloadModule, preinit, and preinitModule exports', async () => {
function App() {
ReactDOM.preload('foo', {as: 'style'});
ReactDOM.preloadModule('foomodule');
ReactDOM.preinit('bar', {as: 'style'});
ReactDOM.preinitModule('barmodule');
return <div>foo</div>;
}
const html = ReactDOMFizzServer.renderToString(<App />);
expect(html).toEqual(
'<link rel="stylesheet" href="bar" data-precedence="default"/><link rel="preload" as="style" href="foo"/><div>foo</div>',
'<link rel="stylesheet" href="bar" data-precedence="default"/><script src="barmodule" type="module" async=""></script><link rel="preload" as="style" href="foo"/><link rel="modulepreload" href="foomodule"/><div>foo</div>',
);
});

Expand Down
2 changes: 2 additions & 0 deletions packages/react-dom/src/server/ReactDOMServerRenderingStub.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

export {
preinit,
preinitModule,
preload,
preloadModule,
preconnect,
prefetchDNS,
} from '../shared/ReactDOMFloat';
Expand Down

0 comments on commit 33b824a

Please sign in to comment.