Skip to content

Commit

Permalink
No string refs (#766)
Browse files Browse the repository at this point in the history
* Use callback ref instead of string ref

* Enable react/no-string-refs rule for xo

* Replace additional string refs

* Fix broken merge
  • Loading branch information
maxdeviant authored and leo committed Oct 7, 2016
1 parent f58b785 commit 0ec2823
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 12 additions & 5 deletions lib/components/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class Term extends Component {
// this.term.CursorNode_ is available at this point.
this.term.setCursorShape(props.cursorShape);
};
this.term.decorate(this.refs.term);
this.term.decorate(this.termRef);
this.term.installKeyboard();
if (this.props.onTerminal) {
this.props.onTerminal(this.term);
Expand Down Expand Up @@ -191,8 +191,8 @@ export default class Term extends Component {
handleMouseDown(ev) {
// we prevent losing focus when clicking the boundary
// wrappers of the main terminal element
if (ev.target === this.refs.term_wrapper ||
ev.target === this.refs.term) {
if (ev.target === this.termWrapperRef ||
ev.target === this.termRef) {
ev.preventDefault();
}
}
Expand Down Expand Up @@ -271,13 +271,20 @@ export default class Term extends Component {

template(css) {
return (<div
ref="term_wrapper"
ref={component => {
this.termWrapperRef = component;
}}
className={css('fit')}
onMouseDown={this.handleMouseDown}
style={{padding: this.props.padding}}
>
{ this.props.customChildrenBefore }
<div ref="term" className={css('fit', 'term')}/>
<div
ref={component => {
this.termRef = component;
}}
className={css('fit', 'term')}
/>
{ this.props.url ?
<webview
src={this.props.url}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
"import/no-extraneous-dependencies": 0,
"no-warning-comments": 0,
"complexity": 0,
"react/no-string-refs": 0,
"react/jsx-key": 0,
"no-nested-ternary": 0,
"react/jsx-no-bind": 0
Expand Down

0 comments on commit 0ec2823

Please sign in to comment.