This is something similar to what i have excluding any others divs:
import React from "react";
export default function Post({post}) {
<div className="postDesc">
{post.sanitizedHtml} //This contains p tag inside
</div>
)
}
This post prop is coming from an api and post.sanitizedHtml basically contains raw html that has tags such as p ,h2 etc.
What i want is to access the p tag that is inside post.sanitizedHtml so that i can use the javascript property .textContent on it and extract the information.
But i think there is no method in react like document.querySelector or document.getElementBy:Id/Classname
Also i think i can't use refs because the data is coming in dynamically and i cant write ref={something} as a prop
So what should i do to access the p tag that is there inside the post.sanitizedHtml ?
Your fast response is appreciated.
dangerouslySetInnerHTML?