title: React - Accessing inline created iframe elements
body: <p>I have an iframe and I'm trying to access it's textarea and add a listener:</p>
  
  <pre><code>    onIframeRef = (node) =&gt; {
         this.Iframe = node;
      };
  
    componentDidMount() {
        let iframeDoc = this.Iframe.contentDocument || this.Iframe.contentWindow.document;
        let textArea = iframeDoc.contentWindow.document.getElementById("some-textarea")[0];
        textArea.addEventListener("input", this.onInput);
     }
  
      render() {
              return &lt;div&gt;
                   &lt;iframe
                    ref={this.onIframeRef}
                    sandbox="allow-same-origin"
                    srcdoc='&lt;html&gt;&lt;body&gt;&lt;textarea id="some-textarea"&gt;&lt;/textarea&gt;&lt;/body&gt;&lt;/html&gt;'
                    &gt;&lt;/iframe&gt;
               &lt;/div&gt; 
      }
  
  </code></pre>
  
  <p>I'm confused as to if setting <code>srcdoc</code> means the code is same origin or not since the code isn't working and <code>this.Iframe</code> has neither <code>contentDocument</code> nor <code>contentWindow</code></p>