aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
author偏右 <afc163@gmail.com>2017-10-22 16:21:35 +0800
committerGitHub <noreply@github.com>2017-10-22 16:21:35 +0800
commitb6767d8a08ccfc52836e09e3a0886a5cf225b93f (patch)
tree234b25acd35bf1c6ea258fe2e8fe22e1e246b9c9
parent2fb27d673619b7bdd70178e617965a009fa72874 (diff)
parented31dbba2c8ef455a973f5548f4d43f244fe8fa2 (diff)
downloadtime-picker-b6767d8a08ccfc52836e09e3a0886a5cf225b93f.tar.gz
time-picker-b6767d8a08ccfc52836e09e3a0886a5cf225b93f.tar.zst
time-picker-b6767d8a08ccfc52836e09e3a0886a5cf225b93f.zip
Merge pull request #66 from react-component/refactor-string-refs
Refactor string refs to callback
-rw-r--r--src/Select.jsx8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Select.jsx b/src/Select.jsx
index 49fed5b..a51ffd2 100644
--- a/src/Select.jsx
+++ b/src/Select.jsx
@@ -79,7 +79,7 @@ class Select extends Component {
79 scrollToSelected(duration) { 79 scrollToSelected(duration) {
80 // move to selected item 80 // move to selected item
81 const select = ReactDom.findDOMNode(this); 81 const select = ReactDom.findDOMNode(this);
82 const list = ReactDom.findDOMNode(this.refs.list); 82 const list = ReactDom.findDOMNode(this.list);
83 if (!list) { 83 if (!list) {
84 return; 84 return;
85 } 85 }
@@ -101,6 +101,10 @@ class Select extends Component {
101 this.setState({ active: false }); 101 this.setState({ active: false });
102 } 102 }
103 103
104 saveList = (node) => {
105 this.list = node;
106 }
107
104 render() { 108 render() {
105 if (this.props.options.length === 0) { 109 if (this.props.options.length === 0) {
106 return null; 110 return null;
@@ -118,7 +122,7 @@ class Select extends Component {
118 onMouseEnter={this.handleMouseEnter} 122 onMouseEnter={this.handleMouseEnter}
119 onMouseLeave={this.handleMouseLeave} 123 onMouseLeave={this.handleMouseLeave}
120 > 124 >
121 <ul ref="list">{this.getOptions()}</ul> 125 <ul ref={this.saveList}>{this.getOptions()}</ul>
122 </div> 126 </div>
123 ); 127 );
124 } 128 }