From e36d972d94fea5ad2814e75a7c112631174bda9d Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 26 Mar 2018 11:36:42 +0100 Subject: [PATCH] Bind function in constructor. --- .../views/context_menus/GenericElementContextMenu.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/views/context_menus/GenericElementContextMenu.js b/src/components/views/context_menus/GenericElementContextMenu.js index 0a8d26929..4ae0bfd7d 100644 --- a/src/components/views/context_menus/GenericElementContextMenu.js +++ b/src/components/views/context_menus/GenericElementContextMenu.js @@ -24,13 +24,18 @@ export default class GenericElementContextMenu extends React.Component { element: PropTypes.element.isRequired, }; + constructor(props) { + super(props); + this.resize = this.resize.bind(this); + } + componentDidMount() { this.resize = this.resize.bind(this); - window.addEventListener("resize", this.resize.bind(this)); + window.addEventListener("resize", this.resize); } componentWillUnmount() { - window.removeEventListener("resize", this.resize.bind(this)); + window.removeEventListener("resize", this.resize); } resize() {