Auto-focus input field in #reactjs after render
If you have a react input field that you want to focus as soon as it is rendered use the autoFocus (case sensitive) attribute:
render() {
  if (this.showPreview) {
    return <div>{this.preview()}</div>;
  } else {
    return <textarea autofocus />;
  }
}
When the condition in the above example becomes falsey the textarea will be rendered and focused.