Move ref callbacks into class bound methods

This commit is contained in:
Ken-Håvard Lieng 2017-02-16 22:56:32 +01:00
parent 77b53bfc5e
commit 531792b14a
4 changed files with 28 additions and 22 deletions

File diff suppressed because one or more lines are too long

View File

@ -68,6 +68,8 @@ export default class MessageBox extends Component {
} }
}; };
listRef = el => { this.list = el; };
handleResize = () => { handleResize = () => {
this.updateWidth(true); this.updateWidth(true);
this.setState({ height: window.innerHeight - 100 }); this.setState({ height: window.innerHeight - 100 });
@ -96,7 +98,7 @@ export default class MessageBox extends Component {
return ( return (
<div className="messagebox"> <div className="messagebox">
<VirtualScroll <VirtualScroll
ref={el => { this.list = el; }} ref={this.listRef}
height={this.state.height} height={this.state.height}
rowsCount={this.props.messages.size + 2} rowsCount={this.props.messages.size + 2}
rowHeight={this.getRowHeight} rowHeight={this.getRowHeight}

View File

@ -10,6 +10,8 @@ export default class Search extends Component {
} }
} }
inputRef = el => { this.input = el; };
handleSearch = e => this.props.onSearch(e.target.value); handleSearch = e => this.props.onSearch(e.target.value);
render() { render() {
@ -27,7 +29,7 @@ export default class Search extends Component {
<div className="search-input-wrap"> <div className="search-input-wrap">
<i className="icon-search" /> <i className="icon-search" />
<input <input
ref={el => { this.input = el; }} ref={this.inputRef}
className="search-input" className="search-input"
type="text" type="text"
onChange={this.handleSearch} onChange={this.handleSearch}

View File

@ -31,6 +31,8 @@ export default class UserList extends Component {
return 24; return 24;
}; };
listRef = el => { this.list = el; };
handleResize = () => this.setState({ height: window.innerHeight - 100 }); handleResize = () => this.setState({ height: window.innerHeight - 100 });
renderUser = index => { renderUser = index => {
@ -65,7 +67,7 @@ export default class UserList extends Component {
return ( return (
<div className={className} style={style}> <div className={className} style={style}>
<VirtualScroll <VirtualScroll
ref={el => { this.list = el; }} ref={this.listRef}
height={this.state.height} height={this.state.height}
rowsCount={this.props.users.size + 2} rowsCount={this.props.users.size + 2}
rowHeight={this.getRowHeight} rowHeight={this.getRowHeight}