Issue
Is it possible to grab a ref from a react element and render it as html? Something like:
const htmlRef = useRef();
const getHtmlFromElement = () => {
return someSortOfFunctionToReturnHTMLStringFromElement(htmlRef.current);
}
return <div ref={htmlRef}>make me html!</div>
I have looked at using ReactDOMServer render to string however my component is burried under various contexts, templates, etc to isolate and render in that manner.
Solution
you are looking for htmlRef.current.outerHTML
Answered By - Antonin Riche
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.