aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
author偏右 <afc163@gmail.com>2017-02-20 16:02:36 +0800
committerGitHub <noreply@github.com>2017-02-20 16:02:36 +0800
commit46e5fd60344c4fa718117e82153773ab0d15ebfc (patch)
treed06f2e3b8e267c242863d10bb983352440ca00b7
parentee6394229b2340c70c342851ecf5dba3462ac4ef (diff)
parent66c7bc36856bbabb4ff73a3ccf671448eed1f359 (diff)
downloadtime-picker-46e5fd60344c4fa718117e82153773ab0d15ebfc.tar.gz
time-picker-46e5fd60344c4fa718117e82153773ab0d15ebfc.tar.zst
time-picker-46e5fd60344c4fa718117e82153773ab0d15ebfc.zip
Merge pull request #29 from fehnomenal/fix-ref-error
Fix react error about refs
-rw-r--r--src/TimePicker.jsx7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx
index e6c2031..da47ac4 100644
--- a/src/TimePicker.jsx
+++ b/src/TimePicker.jsx
@@ -70,6 +70,7 @@ const Picker = React.createClass({
70 }, 70 },
71 71
72 getInitialState() { 72 getInitialState() {
73 this.saveInputRef = refFn.bind(this, 'picker');
73 this.savePanelRef = refFn.bind(this, 'panelInstance'); 74 this.savePanelRef = refFn.bind(this, 'panelInstance');
74 const { defaultOpen, defaultValue, open = defaultOpen, value = defaultValue } = this.props; 75 const { defaultOpen, defaultValue, open = defaultOpen, value = defaultValue } = this.props;
75 return { 76 return {
@@ -105,7 +106,7 @@ const Picker = React.createClass({
105 106
106 onEsc() { 107 onEsc() {
107 this.setOpen(false); 108 this.setOpen(false);
108 this.refs.picker.focus(); 109 this.picker.focus();
109 }, 110 },
110 111
111 onKeyDown(e) { 112 onKeyDown(e) {
@@ -213,7 +214,9 @@ const Picker = React.createClass({
213 <span className={`${prefixCls} ${className}`} style={style}> 214 <span className={`${prefixCls} ${className}`} style={style}>
214 <input 215 <input
215 className={`${prefixCls}-input`} 216 className={`${prefixCls}-input`}
216 ref="picker" type="text" placeholder={placeholder} 217 ref={this.saveInputRef}
218 type="text"
219 placeholder={placeholder}
217 name={name} 220 name={name}
218 readOnly 221 readOnly
219 onKeyDown={this.onKeyDown} 222 onKeyDown={this.onKeyDown}