Skip to content

Commit 4dde645

Browse files
committed
Use better keys in example code
1 parent 8a81be1 commit 4dde645

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

example/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ const Demo = React.createClass({
1818
let replacedText;
1919

2020
// Match URLs
21-
replacedText = reactStringReplace(text, /(https?:\/\/\S+)/g, match => (
22-
<a key={match} href={match}>{match}</a>
21+
replacedText = reactStringReplace(text, /(https?:\/\/\S+)/g, (match, i) => (
22+
<a key={match + i} href={match}>{match}</a>
2323
));
2424

2525
// Match @-mentions
26-
replacedText = reactStringReplace(replacedText, /@(\w+)/g, match => (
27-
<a key={match} href={`https://twitter.com/${match}`}>@{match}</a>
26+
replacedText = reactStringReplace(replacedText, /@(\w+)/g, (match, i) => (
27+
<a key={match + i} href={`https://twitter.com/${match}`}>@{match}</a>
2828
));
2929

3030
// Match hashtags
31-
replacedText = reactStringReplace(replacedText, /#(\w+)/g, match => (
32-
<a key={match} href={`https://twitter.com/hashtag/${match}`}>#{match}</a>
31+
replacedText = reactStringReplace(replacedText, /#(\w+)/g, (match, i) => (
32+
<a key={match + i} href={`https://twitter.com/hashtag/${match}`}>#{match}</a>
3333
));
3434

3535
return (

0 commit comments

Comments
 (0)