mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
* Update Flow to 0.84 * Fix violations * Use inexact object syntax in files from fbsource * Fix warning extraction to use a modern parser * Codemod inexact objects to new syntax * Tighten types that can be exact * Revert unintentional formatting changes from codemod
31 lines
797 B
JavaScript
31 lines
797 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
import React from 'react';
|
|
import {createPortal} from 'react-dom';
|
|
import ErrorBoundary from './ErrorBoundary';
|
|
|
|
export type Props = {portalContainer?: Element, ...};
|
|
|
|
export default function portaledContent(
|
|
Component: React$StatelessFunctionalComponent<any>,
|
|
): React$StatelessFunctionalComponent<any> {
|
|
return function PortaledContent({portalContainer, ...rest}: Props) {
|
|
const children = (
|
|
<ErrorBoundary>
|
|
<Component {...rest} />
|
|
</ErrorBoundary>
|
|
);
|
|
|
|
return portalContainer != null
|
|
? createPortal(children, portalContainer)
|
|
: children;
|
|
};
|
|
}
|