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>
}
Written by MichalHantl
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#React.js
Authors
MichalHantl
24.85K
cleechtech
13.04K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#