1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-06 03:36:46 +00:00
seahub/frontend/src/components/modal-portal.js
JoinTyang cc625f7815
migrate old wiki to new wiki (#6987)
* migrate old wiki to new wiki

* change style

---------

Co-authored-by: Michael An <2331806369@qq.com>
2024-11-05 18:03:53 +08:00

36 lines
656 B
JavaScript

import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
const propTypes = {
children: PropTypes.any.isRequired,
};
const modalRoot = document.getElementById('modal-wrapper');
class ModalPortal extends React.Component {
constructor(props) {
super(props);
this.el = document.createElement('div');
}
componentDidMount() {
modalRoot.appendChild(this.el);
}
componentWillUnmount() {
modalRoot.removeChild(this.el);
}
render() {
return ReactDOM.createPortal(
this.props.children,
this.el,
);
}
}
ModalPortal.propTypes = propTypes;
export default ModalPortal;