onKeyDown = e => {
if (e.key === 'Tab') {
e.preventDefault();
const
input = e.target,
str = input.value,
currPos = input.selectionStart,
wordEnd = str.slice(currPos).search(/[^\w]/);
let pos = str.slice(currPos + wordEnd).search(/[^\s]/);
if (pos) {
pos += currPos + wordEnd;
}
if (pos === currPos) {
pos = 0;
}
input.setSelectionRange(pos, pos);
}
}
<input value={this.state.str} onKeyDown={this.onKeyDown} />