Skip to content

Commit b12fa8a

Browse files
sebmarkbagekoto
authored andcommitted
[Fizz] Add unsupported Portal/Scope components (facebook#21261)
* Update Portal error message * Add Scope Component
1 parent 0c3fe58 commit b12fa8a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/react-server/src/ReactFizzServer.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@ import {
9494
REACT_MEMO_TYPE,
9595
REACT_PROVIDER_TYPE,
9696
REACT_CONTEXT_TYPE,
97+
REACT_SCOPE_TYPE,
9798
} from 'shared/ReactSymbols';
9899
import ReactSharedInternals from 'shared/ReactSharedInternals';
99100
import {
100101
disableLegacyContext,
101102
disableModulePatternComponents,
102103
warnAboutDefaultPropsOnFunctionComponents,
104+
enableScopeAPI,
103105
} from 'shared/ReactFeatureFlags';
104106

105107
import getComponentNameFromType from 'shared/getComponentNameFromType';
@@ -890,6 +892,14 @@ function renderElement(
890892
renderNodeDestructive(request, task, props.children);
891893
return;
892894
}
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
893903
case REACT_SUSPENSE_TYPE: {
894904
renderSuspenseBoundary(request, task, props);
895905
return;
@@ -988,7 +998,12 @@ function renderNodeDestructive(
988998
return;
989999
}
9901000
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
9921007
case REACT_LAZY_TYPE:
9931008
throw new Error('Not yet implemented node type.');
9941009
}

0 commit comments

Comments
 (0)