Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a92731f

Browse files
committed
Extract a child ref from BranchView
1 parent 225bf43 commit a92731f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/controllers/status-bar-tile-controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default class StatusBarTileController extends React.Component {
2626
constructor(props) {
2727
super(props);
2828

29-
this.refBranchView = new RefHolder();
29+
this.refBranchViewRoot = new RefHolder();
3030
}
3131

3232
getChangedFilesCount(data) {
@@ -125,14 +125,14 @@ export default class StatusBarTileController extends React.Component {
125125
/>
126126
</Commands>
127127
<BranchView
128-
ref={this.refBranchView.setter}
128+
refRoot={this.refBranchViewRoot.setter}
129129
workspace={this.props.workspace}
130130
checkout={this.checkout}
131131
currentBranch={repoProps.currentBranch}
132132
/>
133133
<Tooltip
134134
manager={this.props.tooltips}
135-
target={this.refBranchView}
135+
target={this.refBranchViewRoot}
136136
trigger="click"
137137
className="github-StatusBarTileController-tooltipMenu">
138138
<BranchMenuView

lib/views/branch-view.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import cx from 'classnames';
34

45
import {BranchPropType} from '../prop-types';
56

67
export default class BranchView extends React.Component {
78
static propTypes = {
89
currentBranch: BranchPropType.isRequired,
10+
refRoot: PropTypes.func,
11+
}
12+
13+
static defaultProps = {
14+
refRoot: () => {},
915
}
1016

1117
render() {
@@ -14,7 +20,7 @@ export default class BranchView extends React.Component {
1420
);
1521

1622
return (
17-
<div className={classNames} ref={e => { this.element = e; }}>
23+
<div className={classNames} ref={this.props.refRoot}>
1824
<span className="icon icon-git-branch" />
1925
<span className="branch-label">{this.props.currentBranch.getName()}</span>
2026
</div>

0 commit comments

Comments
 (0)