Skip to content Skip to sidebar Skip to footer

How To Render Raw Html Content To React Pass Via Props?

I'm trying to pass a variable in return of a component. Here is my code: const Obj = (props) => { let { propId } = useParams(); const [data, setData] = useState({

Solution 1:

Try the dangerouslySetInnerHTML attribute :

 <Fragment key={propId}>
            <div dangerouslySetInnerHTML={ { __html: data.htmlContent}} >
           
            </div>
        </Fragment>

Post a Comment for "How To Render Raw Html Content To React Pass Via Props?"