@@ -82,8 +82,8 @@ class TagsInput extends React.Component {
8282 constructor ( ) {
8383 super ( )
8484 this . state = { tag : '' , isFocused : false }
85- this . focus = :: this . focus
86- this . blur = :: this . blur
85+ this . focus = this . focus . bind ( this )
86+ this . blur = this . blur . bind ( this )
8787 }
8888
8989 static propTypes = {
@@ -420,19 +420,19 @@ class TagsInput extends React.Component {
420420 } )
421421 }
422422
423- componentWillReceiveProps ( nextProps ) {
423+ componentDidUpdate ( prevProps ) {
424424 /* istanbul ignore next */
425425 if ( this . hasControlledInput ( ) ) {
426426 return
427427 }
428428
429- if ( ! this . inputValue ( nextProps ) ) {
429+ if ( ! this . inputValue ( this . props ) ) {
430430 return
431431 }
432432
433- this . setState ( {
434- tag : this . inputValue ( nextProps )
435- } )
433+ if ( this . inputValue ( prevProps ) !== this . inputValue ( this . props ) ) {
434+ this . setState ( { tag : this . inputValue ( this . props ) } )
435+ }
436436 }
437437
438438 render ( ) {
@@ -474,27 +474,27 @@ class TagsInput extends React.Component {
474474 return renderTag ( {
475475 key : index ,
476476 tag,
477- onRemove : :: this . handleRemove ,
477+ onRemove : this . handleRemove . bind ( this ) ,
478478 disabled,
479- getTagDisplayValue : :: this . _getTagDisplayValue ,
479+ getTagDisplayValue : this . _getTagDisplayValue . bind ( this ) ,
480480 ...tagProps
481481 } )
482482 } )
483483
484484 let inputComponent = renderInput ( {
485485 ref : r => { this . input = r } ,
486486 value : this . _tag ( ) ,
487- onPaste : :: this . handlePaste ,
488- onKeyDown : :: this . handleKeyDown ,
489- onChange : :: this . handleChange ,
490- onFocus : :: this . handleOnFocus ,
491- onBlur : :: this . handleOnBlur ,
492- addTag : :: this . addTag ,
487+ onPaste : this . handlePaste . bind ( this ) ,
488+ onKeyDown : this . handleKeyDown . bind ( this ) ,
489+ onChange : this . handleChange . bind ( this ) ,
490+ onFocus : this . handleOnFocus . bind ( this ) ,
491+ onBlur : this . handleOnBlur . bind ( this ) ,
492+ addTag : this . addTag . bind ( this ) ,
493493 ...this . inputProps ( )
494494 } )
495495
496496 return (
497- < div ref = { r => { this . div = r } } onClick = { :: this . handleClick } className = { className } >
497+ < div ref = { r => { this . div = r } } onClick = { this . handleClick . bind ( this ) } className = { className } >
498498 { renderLayout ( tagComponents , inputComponent ) }
499499 </ div >
500500 )
0 commit comments