title: React get codemirror value onClick
body: <p>I am trying to get the following code below to display the CodeMirror onChange value when the button is clicked and then display that value inside the "output" div.</p>
  
  <p>I am fairly new to react so not sure if it's best to pass the value through state or if there's an easier method.</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>import React, { Component } from "react";
  import { UnControlled as CodeMirror } from "react-codemirror2";
  import "codemirror/mode/javascript/javascript";
  import "codemirror/lib/codemirror.css";
  
  export default class Code extends Component {
    render() {
      return (
        &lt;div&gt;
          &lt;CodeMirror
            value='console.log("Hello World")'
            options={{
              mode: "javascript",
              lineNumbers: true
            }}
            onChange={(editor, data, value) =&gt; {
              console.log(value);
            }}
          /&gt;
          &lt;button onClick={}&gt;run code&lt;/button&gt;
  
          &lt;div className="Output"&gt;
            &lt;p&gt;// Value should go here&lt;/p&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      );
    }
  }
  </code></pre>