Skip to content

Commit 42c3897

Browse files
committed
Merge branch 'master' of github.com:iansinnott/react-string-replace
2 parents 932a8f1 + a9847e5 commit 42c3897

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const HighlightNumbers = React.createClass({
5454
const content = 'Hey my number is 555-555-5555.';
5555
return (
5656
<div>
57-
{reactStringReplace(this.props.content, /(\d+)/g, (match, i) => (
57+
{reactStringReplace(content, /(\d+)/g, (match, i) => (
5858
<span key={i} style={{ color: 'red' }}>{match}</span>
5959
))}
6060
</div>
@@ -74,18 +74,18 @@ const text = 'Hey @ian_sinn, check out this link https://github.com/iansinnott/
7474
let replacedText;
7575

7676
// Match URLs
77-
replacedText = replaceString(text, /(https?:\/\/\S+)/g, match => (
78-
<a href={match}>{match}</a>
77+
replacedText = reactStringReplace(text, /(https?:\/\/\S+)/g, (match, i) => (
78+
<a key={match + i} href={match}>{match}</a>
7979
));
8080

8181
// Match @-mentions
82-
replacedText = replaceString(replacedText, /@(\w+)/g, match => (
83-
<a href={`https://twitter.com/${match}`}>@{match}</a>
82+
replacedText = reactStringReplace(replacedText, /@(\w+)/g, (match, i) => (
83+
<a key={match + i} href={`https://twitter.com/${match}`}>@{match}</a>
8484
));
8585

8686
// Match hashtags
87-
replacedText = replaceString(replacedText, /#(\w+)/g, match => (
88-
<a href={`https://twitter.com/hashtag/${match}`}>#{match}</a>
87+
replacedText = reactStringReplace(replacedText, /#(\w+)/g, (match, i) => (
88+
<a key={match + i} href={`https://twitter.com/hashtag/${match}`}>#{match}</a>
8989
));
9090

9191
// => [

0 commit comments

Comments
 (0)