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

Function Foo

packages/react-dom/src/__tests__/ReactDOMFizzSuspenseList-test.js:857–912  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

855 const A = createAsyncText('A');
856
857 function Foo() {
858 return (
859 <div>
860 <SuspenseList revealOrder="forwards" tail="visible">
861 <Suspense fallback={<Text text="Loading A" />}>
862 <A />
863 </Suspense>
864 <Suspense fallback={<Text text="Loading B" />}>
865 <Text text="B" />
866 </Suspense>
867 </SuspenseList>
868 </div>
869 );
870 }
871
872 const errors = [];
873 await serverAct(async () => {
874 const {pipe} = ReactDOMFizzServer.renderToPipeableStream(<Foo />, {
875 onError(error) {
876 errors.push(error.message);
877 },
878 });
879 pipe(writable);
880 });
881
882 assertLog([
883 'Suspend! [A]',
884 'B', // TODO: Defer rendering the content after fallback if previous suspended,
885 'Loading A',
886 'Loading B',
887 ]);
888
889 expect(getVisibleChildren(container)).toEqual(
890 <div>
891 <span>Loading A</span>
892 <span>Loading B</span>
893 </div>,
894 );
895
896 await serverAct(async () => {
897 A.reject(new Error('hi'));
898 });
899
900 assertLog(['Error! [hi]']);
901
902 expect(getVisibleChildren(container)).toEqual(
903 <div>
904 <span>Loading A</span>
905 <span>B</span>
906 </div>,
907 );
908
909 expect(errors).toEqual(['hi']);
910 expect(hasErrored).toBe(false);
911 expect(hasCompleted).toBe(true);
912 });
913});

Callers

nothing calls this directly

Calls 7

getVisibleChildrenFunction · 0.90
onErrorFunction · 0.70
serverActFunction · 0.70
pushMethod · 0.65
toEqualMethod · 0.65
toBeMethod · 0.65
assertLogFunction · 0.50

Tested by

no test coverage detected