ReactJS render string with non-breaking spaces
I know this is an old question, and this doesn't exactly do what you asked for, but rather than editing the string, what you want to achieve is probably be solved better using the CSS white-space: nowrap
attribute:
In html:
<div style="white-space: nowrap">This won't break lines</div>
In react:
<div style={{ whiteSpace: 'nowrap' }}>{myValue}</div>