title: insert at cursor in react
body: <p>I need to insert text at caret (current cursor position) in the <a href="http://facebook.github.io/react/" rel="noreferrer">React</a>-controlled textarea (like autocomplete).</p>
  
  <p>For vanilla textarea I used this code:</p>
  
  <pre><code>insertAtCursor: function (myField, myValue) {
      // IE
      if (document.selection) {
          myField.focus();
          var sel = document.selection.createRange();
          sel.text = myValue;
      } 
      // FF
      else if (myField.selectionStart || myField.selectionStart == '0') {
          var startPos = myField.selectionStart;  var endPos = myField.selectionEnd;
          myField.value = myField.value.substring(0, startPos)
          + myValue + myField.value.substring(endPos, myField.value.length);
      } else {
          myField.value += myValue;
      }
  }
  </code></pre>
  
  <p>but it does not work in React. How can I do it?</p>