score:7

Accepted answer

you can add a ref to your span

let spanref = react.createref()
...
<span ref={spanref}>some static text: {somedynamictext}, {someanothertext}</span>

then the text length would simply be spanref.current.textcontent.length

score:8

why not, first, compose the whole string? you can grab its length immediately after, and then render it.

const spanstr = `some static text: ${somedynamictext}, ${someanothertext}`;
const spanlength = spanstr.length;

return(
  <somecomp>
     ...
     <span>{spanstr}</span>
     ...
  </somecomp>
)

Related Query

More Query from same tag