Skip to content

Commit 3a09245

Browse files
committed
Fix type error and improve name of portal container flag
**NOTE:** I am still looking for a good place to move this flag assignment to, or a better approach. This does some intermediate fixes. **what is the change?:** - fixed flow error by allowing optional flag on a DOMContainer that indicates it was used as a portal container. - renamed the flag to something which makes more sense **why make this change?:** - get Flow passing - make this change make more sense We are still not sure about adding this flag; a follow-up diff may move it or take a different approach. **test plan:** `yarn test` **issue:** #8854
1 parent e1f3854 commit 3a09245

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/renderers/dom/fiber/ReactDOMFiberEntry.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,14 @@ findDOMNode._injectFiber(function(fiber: Fiber) {
7373
});
7474

7575
type DOMContainer =
76-
| (Element & {_reactRootContainer: ?Object})
77-
| (Document & {_reactRootContainer: ?Object});
76+
| (Element & {
77+
_reactRootContainer: ?Object,
78+
__reactInternalIsPortalContainer: ?boolean,
79+
})
80+
| (Document & {
81+
_reactRootContainer: ?Object,
82+
__reactInternalIsPortalContainer: ?boolean,
83+
});
7884

7985
type Container = Element | Document;
8086
type Props = {
@@ -538,7 +544,7 @@ function renderSubtreeIntoContainer(
538544
const hostInstanceParentIsPortal =
539545
hostInstance &&
540546
hostInstance.parentNode &&
541-
hostInstance.parentNode._reactPortalContainer;
547+
hostInstance.parentNode.__reactInternalIsPortalContainer;
542548
if (hostInstance && !hostInstanceParentIsPortal) {
543549
warning(
544550
hostInstance.parentNode === container,

src/renderers/shared/fiber/isomorphic/ReactPortal.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ exports.createPortal = function(
2727
implementation: any,
2828
key: ?string = null,
2929
): ReactPortal {
30-
containerInfo._reactPortalContainer = {};
30+
// This flag allows us to check if a node was used with a portal
31+
containerInfo.__reactInternalIsPortalContainer = true;
3132
return {
3233
// This tag allow us to uniquely identify this as a React Portal
3334
$$typeof: REACT_PORTAL_TYPE,

0 commit comments

Comments
 (0)