MCPcopy
hub / github.com/facebook/react / Abort

Function Abort

packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js:9609–9652  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9607
9608 const controller = new AbortController();
9609 function Abort() {
9610 controller.abort();
9611 return <Comp />;
9612 }
9613
9614 function Comp() {
9615 return null;
9616 }
9617
9618 function App() {
9619 return (
9620 <html>
9621 <head>
9622 <meta content="here" />
9623 </head>
9624 <body>
9625 <main>hello</main>
9626 <Suspense>
9627 <Pending />
9628 </Suspense>
9629 <Abort />
9630 </body>
9631 </html>
9632 );
9633 }
9634
9635 const signal = controller.signal;
9636
9637 let thrownError = null;
9638 const errors = [];
9639 try {
9640 await act(() => {
9641 const {pipe, abort} = renderToPipeableStream(<App />, {
9642 onError(e, ei) {
9643 errors.push({
9644 error: e,
9645 componentStack: normalizeCodeLocInfo(ei.componentStack),
9646 });
9647 },
9648 });
9649 signal.addEventListener('abort', () => abort('boom'));
9650 pipe(writable);
9651 });
9652 } catch (e) {
9653 thrownError = e;
9654 }
9655

Callers

nothing calls this directly

Calls 8

actFunction · 0.70
renderToPipeableStreamFunction · 0.70
onErrorFunction · 0.70
normalizeCodeLocInfoFunction · 0.70
abortMethod · 0.65
pushMethod · 0.65
abortFunction · 0.50
pipeFunction · 0.50

Tested by

no test coverage detected