Skip to content

Commit 9cb8315

Browse files
committed
Support fragments and fragment like types
1 parent 37c336c commit 9cb8315

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

packages/react-server/src/ReactFizzServer.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ import {
6262
REACT_PORTAL_TYPE,
6363
REACT_LAZY_TYPE,
6464
REACT_SUSPENSE_TYPE,
65+
REACT_LEGACY_HIDDEN_TYPE,
66+
REACT_DEBUG_TRACING_MODE_TYPE,
67+
REACT_STRICT_MODE_TYPE,
68+
REACT_PROFILER_TYPE,
69+
REACT_SUSPENSE_LIST_TYPE,
70+
REACT_FRAGMENT_TYPE,
6571
} from 'shared/ReactSymbols';
6672
import ReactSharedInternals from 'shared/ReactSharedInternals';
6773
import {
@@ -703,10 +709,32 @@ function renderElement(
703709
}
704710
} else if (typeof type === 'string') {
705711
renderHostElement(request, task, type, props);
706-
} else if (type === REACT_SUSPENSE_TYPE) {
707-
renderSuspenseBoundary(request, task, props);
708712
} else {
709-
throw new Error('Not yet implemented element type.');
713+
switch (type) {
714+
// TODO: LegacyHidden acts the same as a fragment. This only works
715+
// because we currently assume that every instance of LegacyHidden is
716+
// accompanied by a host component wrapper. In the hidden mode, the host
717+
// component is given a `hidden` attribute, which ensures that the
718+
// initial HTML is not visible. To support the use of LegacyHidden as a
719+
// true fragment, without an extra DOM node, we would have to hide the
720+
// initial HTML in some other way.
721+
case REACT_LEGACY_HIDDEN_TYPE:
722+
case REACT_DEBUG_TRACING_MODE_TYPE:
723+
case REACT_STRICT_MODE_TYPE:
724+
case REACT_PROFILER_TYPE:
725+
case REACT_SUSPENSE_LIST_TYPE: // TODO: SuspenseList should control the boundaries.
726+
case REACT_FRAGMENT_TYPE: {
727+
renderNodeDestructive(request, task, props.children);
728+
break;
729+
}
730+
case REACT_SUSPENSE_TYPE: {
731+
renderSuspenseBoundary(request, task, props);
732+
break;
733+
}
734+
default: {
735+
throw new Error('Not yet implemented element type.');
736+
}
737+
}
710738
}
711739
}
712740

0 commit comments

Comments
 (0)