title: Reactjs - what is the workflow to force a refresh?
body: <p>I'm just trying to create a react component wrapping the CodeMirror (4.1) editor. </p>
  
  <p>I came across <a href="https://github.com/marijnh/CodeMirror/issues/1891" rel="nofollow noreferrer">this problem</a> for which there is a workround via forcing a refresh once the component has loaded, but I'm not quite sure of the workflow I need to achieve this when react is added into the picture.</p>
  
  <p>The suggestion is that to overcome the error I would need to </p>
  
  <blockquote>
    <p>"Call .refresh() after resizing the wrapping container."</p>
  </blockquote>
  
  <p>My code is currently as follows in the Editor component:</p>
  
  <pre><code>  function ($, React, CodeMirror) {
  
      return React.createClass({
  
        render: function () {
          console.log("render-editarea");
          return (
            &lt;textarea id="editarea"&gt;
  -- Comment here
  USE [All Data Items];
  SELECT ID FROM [Test Event]
            &lt;/textarea&gt;
          )
        },
  
        componentDidMount: function () { 
          var onExecute = this.props.onExecute;
          var editorNode = document.getElementById("editarea");
          console.log("componentDidUpdate-editarea:" + editorNode); 
          var editor = CodeMirror.fromTextArea(editorNode, {        
            lineNumbers: true,
            matchBrackets: true,
            indentUnit: 4,
            mode: "text/x-mssql",
            extraKeys: {"Ctrl-E": function(cm) {    
              console.log(editor.getValue());
              onExecute(editor.getValue());
            }}
          });
        },
  </code></pre>
  
  <p>and it is loaded via the Render function of the parent component</p>
  
  <p>I have tried </p>
  
  <ul>
  <li>hooking the window resize event (as shown in the React manual) in
  the editor component.</li>
  <li>forcing a refresh in the parent component's <code>componentDidMount</code>
  function using <code>$("#editarea").refresh();</code></li>
  </ul>
  
  <p>but neither of these appeared to work</p>
  
  <p>So I'd be grateful if someone could show me the right way to do it.</p>
  
  <p>Many thx</p>