I\'m trying to replace parts of a string with JSX tags, like so:
render: function() {
result = this.props.text.replace(\":\",
The accepted answer is two years old. For this problem issue #3368 was created and based on the solution provided by a Facebook employee working on React, react-string-replace was created.
Using react-string-replace, here is how you can solve your problem
const reactStringReplace = require('react-string-replace');
const HighlightNumbers = React.createClass({
render() {
const content = 'Hey my number is 555:555:5555.';
return (
{reactStringReplace(content, ':', (match, i) => (
))}
);
},
});