[Fizz] Add unsupported Portal/Scope components (#21261)
* Update Portal error message * Add Scope Component
Sebastian Markbåge committed
Apr 14, 2021 at 17:35 UTC
a4a940d7a15814e50c977179f7d2be3c76611707
1 file changed
+16
-1
packages/react-server/src/ReactFizzServer.js
+16
-1
@@ -94,12 +94,14 @@ import {
94
REACT_MEMO_TYPE,
95
REACT_PROVIDER_TYPE,
96
REACT_CONTEXT_TYPE,
97
+ REACT_SCOPE_TYPE,
98
} from 'shared/ReactSymbols';
99
import ReactSharedInternals from 'shared/ReactSharedInternals';
100
import {
101
disableLegacyContext,
102
disableModulePatternComponents,
103
warnAboutDefaultPropsOnFunctionComponents,
104
+ enableScopeAPI,
105
} from 'shared/ReactFeatureFlags';
106
107
import getComponentNameFromType from 'shared/getComponentNameFromType';
@@ -890,6 +892,14 @@ function renderElement(
892
renderNodeDestructive(request, task, props.children);
893
return;
894
}
895
+ case REACT_SCOPE_TYPE: {
896
+ if (enableScopeAPI) {
897
+ renderNodeDestructive(request, task, props.children);
898
+ return;
899
+ }
900
+ invariant(false, 'ReactDOMServer does not yet support scope components.');
901
+ }
902
+ // eslint-disable-next-line-no-fallthrough
903
case REACT_SUSPENSE_TYPE: {
904
renderSuspenseBoundary(request, task, props);
905
return;
@@ -988,7 +998,12 @@ function renderNodeDestructive(
998
return;
999
}
1000
case REACT_PORTAL_TYPE:
991
- throw new Error('Not yet implemented node type.');
1001
+ invariant(
1002
+ false,
1003
+ 'Portals are not currently supported by the server renderer. ' +
1004
+ 'Render them conditionally so that they only appear on the client render.',
1005
+ );
1006
+ // eslint-disable-next-line-no-fallthrough
1007
case REACT_LAZY_TYPE:
1008
throw new Error('Not yet implemented node type.');
1009
}