You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
389 B
19 lines
389 B
6 years ago
|
import PropTypes from 'prop-types';
|
||
|
import ReactDOM from 'react-dom';
|
||
|
|
||
|
function Portal(props) {
|
||
|
const { children, target } = props;
|
||
|
return ReactDOM.createPortal(children, target);
|
||
|
}
|
||
|
|
||
|
Portal.propTypes = {
|
||
|
children: PropTypes.node.isRequired,
|
||
|
target: PropTypes.object.isRequired
|
||
|
};
|
||
|
|
||
|
Portal.defaultProps = {
|
||
|
target: document.getElementById('portal-root')
|
||
|
};
|
||
|
|
||
|
export default Portal;
|