Answer the question
In order to leave comments, you need to log in
How to get innerHTML React element by ref?
There is an element like
<div ref={el = this.TestElement = el } style={{...}}><h1>xxx</h1></div>
Answer the question
In order to leave comments, you need to log in
const testElementHtml = this.TestElement.parentNode.innerHTML
const testElementClone = this.TestElement.cloneNode(true)
const wrap = document.createElement('div')
wrap.appendChild(testElementClone)
const testElementHtml = wrap.innerHTML
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question