Files
Hydro/packages/ui-default/components/react/DomComponent.jsx
T
undefined 5faa54c7ca ui-default: init
将ui-default合并至主存储库便于维护
2021-04-03 01:44:22 +08:00

27 lines
499 B
React

import React from 'react';
import PropTypes from 'prop-types';
export default class DomComponent extends React.PureComponent {
componentDidMount() {
this.refs.dom.appendChild(this.props.childDom);
}
componentWillUnmount() {
$(this.refs.dom).empty();
}
render() {
const {
childDom,
...rest
} = this.props;
return (
<div {...rest} ref="dom"></div>
);
}
}
DomComponent.propTypes = {
childDom: PropTypes.instanceOf(HTMLElement).isRequired,
};