0iz_zq
Last Updated: November 03, 2017
·
4.912K
· MichalHantl

How to put focus at the end of an input with React.js

Pretty easy to do, but couldn't find it in 1 minute so posting here :)

moveCaretAtEnd(e) {
  var temp_value = e.target.value
  e.target.value = ''
  e.target.value = temp_value
}


render() {
  <textarea 
    value={value}
    autoFocus
    onFocus={this.moveCaretAtEnd}
  ></textarea>
}
Say Thanks
Respond