MCPcopy Index your code
hub / github.com/react/react / writeHoistables

Function writeHoistables

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js:5637–5688  ·  view source on GitHub ↗
(
  destination: Destination,
  resumableState: ResumableState,
  renderState: RenderState,
)

Source from the content-addressed store, hash-verified

5635// in the future to be backpressure sensitive but that requires a larger refactor
5636// of the flushing code in Fizz.
5637export function writeHoistables(
5638 destination: Destination,
5639 resumableState: ResumableState,
5640 renderState: RenderState,
5641): void {
5642 let i = 0;
5643
5644 // Emit high priority Hoistables
5645
5646 // We omit charsetChunks because we have already sent the shell and if it wasn't
5647 // already sent it is too late now.
5648
5649 const viewportChunks = renderState.viewportChunks;
5650 for (i = 0; i < viewportChunks.length; i++) {
5651 writeChunk(destination, viewportChunks[i]);
5652 }
5653 viewportChunks.length = 0;
5654
5655 renderState.preconnects.forEach(flushResource, destination);
5656 renderState.preconnects.clear();
5657
5658 renderState.fontPreloads.forEach(flushResource, destination);
5659 renderState.fontPreloads.clear();
5660
5661 renderState.highImagePreloads.forEach(flushResource, destination);
5662 renderState.highImagePreloads.clear();
5663
5664 // Preload any stylesheets. these will emit in a render instruction that follows this
5665 // but we want to kick off preloading as soon as possible
5666 renderState.styles.forEach(preloadLateStyles, destination);
5667
5668 // We only hoist importmaps that are configured through createResponse and that will
5669 // always flush in the preamble. Generally we don't expect people to render them as
5670 // tags when using React but if you do they are going to be treated like regular inline
5671 // scripts and flush after other hoistables which is problematic
5672
5673 // bootstrap scripts should flush above script priority but these can only flush in the preamble
5674 // so we elide the code here for performance
5675
5676 renderState.scripts.forEach(flushResource, destination);
5677 renderState.scripts.clear();
5678
5679 renderState.bulkPreloads.forEach(flushResource, destination);
5680 renderState.bulkPreloads.clear();
5681
5682 // Write embedding hoistableChunks
5683 const hoistableChunks = renderState.hoistableChunks;
5684 for (i = 0; i < hoistableChunks.length; i++) {
5685 writeChunk(destination, hoistableChunks[i]);
5686 }
5687 hoistableChunks.length = 0;
5688}
5689
5690export function writePostamble(
5691 destination: Destination,

Callers 1

flushCompletedQueuesFunction · 0.90

Calls 3

writeChunkFunction · 0.90
forEachMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected