Call for update on window resize.

This commit is contained in:
Richard Lewis 2018-01-18 12:01:29 +00:00
parent c340032bd1
commit 738b59fd42
1 changed files with 15 additions and 0 deletions

View File

@ -24,6 +24,21 @@ export default class GenericElementContextMenu extends React.Component {
element: PropTypes.element.isRequired,
};
componentDidMount() {
this.resize = this.resize.bind(this);
window.addEventListener("resize", this.resize.bind(this));
}
componentWillUnmount() {
window.removeEventListener("resize", this.resize.bind(this));
}
resize() {
if (this.props.onResize) {
this.props.onResize();
}
}
render() {
return <div>{ this.props.element }</div>;
}