I'm trying to replace parts of a string with JSX tags, like so:
render: function() {
result = this.props.text.replace(":",<div className="spacer"></div>);
return (
<div>
{result}
<div>
);
}
But given that this.props.text
is Lorem : ipsum
, it results in
<div>
Lorem [object Object] ipsum.
</div>
Is there a way to solve this or another way to replace parts of a string with JSX tags?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…