mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-06 17:33:18 +00:00
Optimized wiki code (#2566)
* optimized path component * abstract component * repair copy bug * move copy&move&download to list-item * add modal portal
This commit is contained in:
35
frontend/src/components/modal-portal.js
Normal file
35
frontend/src/components/modal-portal.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const propTypes = {
|
||||
children: PropTypes.object.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;
|
Reference in New Issue
Block a user