]> git.immae.eu Git - github/fretlink/time-picker.git/commitdiff
Fix react error about refs
authorAndreas Fehn <andi.fehn@gmail.com>
Sat, 4 Feb 2017 06:57:06 +0000 (07:57 +0100)
committerAndreas Fehn <andi.fehn@gmail.com>
Sat, 4 Feb 2017 06:57:06 +0000 (07:57 +0100)
src/TimePicker.jsx

index ec3eda07573f10bf9b765d0d4306c0b43c91763d..28857a07796da025a5a139d436f6e019ff19353e 100644 (file)
@@ -69,6 +69,7 @@ const Picker = React.createClass({
   },
 
   getInitialState() {
+    this.saveInputRef = refFn.bind(this, 'picker');
     this.savePanelRef = refFn.bind(this, 'panelInstance');
     const { defaultOpen, defaultValue, open = defaultOpen, value = defaultValue } = this.props;
     return {
@@ -104,7 +105,7 @@ const Picker = React.createClass({
 
   onEsc() {
     this.setOpen(false);
-    this.refs.picker.focus();
+    this.picker.focus();
   },
 
   onKeyDown(e) {
@@ -212,7 +213,7 @@ const Picker = React.createClass({
         <span className={`${prefixCls} ${className}`} style={style}>
           <input
             className={`${prefixCls}-input`}
-            ref="picker" type="text" placeholder={placeholder}
+            ref={this.saveInputRef} type="text" placeholder={placeholder}
             readOnly
             onKeyDown={this.onKeyDown}
             disabled={disabled} value={value && value.format(this.getFormat()) || ''}