Skip to content

Commit

Permalink
Move non-binding functions out of constructor
Browse files Browse the repository at this point in the history
Only the clearSelectedNode binding needs to be kept in the constructor.
  • Loading branch information
victorlin committed Oct 9, 2024
1 parent 2a45510 commit a1aec38
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/components/tree/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a1aec38

Please sign in to comment.