Retrieving RichText HTML
Approach 1
import React, { useEffect, useRef, Fragment } from "react";
// Option A — log the rendered HTML (what ends up in the DOM)
interface MyComponentProps {
content?: React.ReactNode;
}
export const MyComponent = ({ content }: MyComponentProps) => {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (ref.current) console.log(ref.current.innerHTML);
}, [content]);
return (
<div ref={ref} className="content-wrapper">
{content}
</div>
);
};
Approach 2
Last updated