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.
CodePudding user response:
you are looking for htmlRef.current.outerHTML