Is there a way to get text content from a React element stored in a variable without ref?
There is a functional component, that receives title
prop, which contains react element:
function component({ title }) {
const content = title.textContent() // Need Something like this
}
and this title
prop might have react node like: <div>Some Title</div>
. But I'd like to get only content of the node, in a variable before rendering it. Is it possible?
When I console.log title
variable this is the output, The content I want is inside props.children
array, so is there a method to get it without traversing through keys: