Skip to content

Commit

Permalink
Fix ReactDOM Flow Types
Browse files Browse the repository at this point in the history
Now that ReactDOM is Flow type checked we need to fix up its types.
  • Loading branch information
sebmarkbage committed Feb 24, 2020
1 parent fde18cf commit 718be6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,20 @@ setBatchingImplementation(
);

export type DOMContainer =
| (Element & {_reactRootContainer: ?RootType, ...})
| (Document & {_reactRootContainer: ?RootType, ...});
| (Element & {_reactRootContainer?: RootType, ...})
| (Document & {_reactRootContainer?: RootType, ...});

function createPortal(
children: ReactNodeList,
container: DOMContainer,
key: ?string = null,
) {
): React$Portal {
invariant(
isValidContainer(container),
'Target container is not a DOM element.',
);
// TODO: pass ReactDOM portal implementation as third argument
// $FlowFixMe The Flow type is opaque but there's no way to actually create it.
return createPortalImpl(children, container, null, key);
}

Expand Down
1 change: 1 addition & 0 deletions packages/react-dom/src/client/ReactDOMLegacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ export function unmountComponentAtNode(container: DOMContainer) {
// Unmount should not be batched.
unbatchedUpdates(() => {
legacyRenderSubtreeIntoContainer(null, null, container, false, () => {
// $FlowFixMe This should probably use `delete container._reactRootContainer`
container._reactRootContainer = null;
unmarkContainerAsRoot(container);
});
Expand Down

0 comments on commit 718be6e

Please sign in to comment.