We can not use el.innerText to retrieve text from JSX because it is not an HTML element. Let's put a simple JSX in the dev tool's console console.dir(<>Hello <strong>Mike</strong></>) We got the nested object with children in props . Let's recursively go through it and take all the text out.
function jsxToStr(el) {
if (!el) return ''
if (typeof el === 'string') return el
const children = el.props && el.props.children
if (children instanceof Array) { return children.map(jsxToStr).join('') }
return jsxToStr(children)
}
jsxToStr(<>Hello <strong>Mike</strong></>) // 'Hello Mike'
Note that we get text from the static JSX, but not from the component function result after JSX call.