You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
499 B
JavaScript
27 lines
499 B
JavaScript
5 years ago
|
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,
|
||
|
};
|