From a1aec383711667c0d4c26292445eb0a4f07b2f32 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:55:02 -0700 Subject: [PATCH] Move non-binding functions out of constructor Only the clearSelectedNode binding needs to be kept in the constructor. --- src/components/tree/tree.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/components/tree/tree.js b/src/components/tree/tree.js index bba1cb0f6..264523d67 100644 --- a/src/components/tree/tree.js +++ b/src/components/tree/tree.js @@ -35,19 +35,22 @@ class Tree extends React.Component { tree: null, treeToo: null }; + /* bind callbacks */ this.clearSelectedNode = callbacks.clearSelectedNode.bind(this); - this.redrawTree = () => { - this.props.dispatch(updateVisibleTipsAndBranchThicknesses({ - root: [0, 0] - })); - }; - /* pressing the escape key should dismiss an info modal (if one exists) */ - this.handlekeydownEvent = (event) => { - if (event.key==="Escape" && this.props.selectedNode) { - this.clearSelectedNode(this.props.selectedNode); - } - }; + } + + redrawTree = () => { + this.props.dispatch(updateVisibleTipsAndBranchThicknesses({ + root: [0, 0] + })); + } + + /* pressing the escape key should dismiss an info modal (if one exists) */ + handlekeydownEvent = (event) => { + if (event.key==="Escape" && this.props.selectedNode) { + this.clearSelectedNode(this.props.selectedNode); + } } setUpAndRenderTreeToo(props, newState) {