I have some props that has a string that could contain characters such as &.
It also contains spaces. I want to replace all spaces with .
Is there an easy way I can do this? Bear in mind that I cannot just render using this syntax:
<div dangerouslySetInnerHTML={{__html: myValue}} />
because I would first have to replace any HTML entities with their markup. I don't want to have to do this, it seems too low level.
Is there a way I can do this?
 l;, do you want to display HTML tags literally or is there something else you want to do?myValueis accessible. You could wait for it in appropriate lifecycle function, parse it and set aparsedflag that prevents multiple parsing.dangerouslySetInnerHTMLmethod. I don't really see a way around that since you could use javascript to create a string replacing spaces with but without using thedangerouslySetInnerHTMLmethod these will be escaped by react.