I have a function where i want to return some HTML but when I call the function, or log it, it returns the variable as undefined:
contentForRender = () => {
const el = (
<div><span>Lorem Ipsum</span></div>
);
return el;
}
componentDidUpdate(prevProps, prevState, prevContext) {
const el = this.contentForRender();
console.log('el', el);
console.log('el_inner', el.innerHTML);
// do something with el.innerHTML
}
When i log it out, the 'el' variable in componentDidUpdate is typeOf: Symbol(react.element)
and el.innerHTML is undefined
.
Is there a different way of getting innerHTML for a React element?
I've tried using refs, but as I'm still reasonably new to React I'm not sure I've been doing it correctly and cant think of why it isn't working. Any help will be really appreciated!