fix: Various React warnings

This commit is contained in:
Tom Moor
2020-11-08 20:28:27 -08:00
parent 0372ff2727
commit 14e0ed8108
7 changed files with 33 additions and 32 deletions

View File

@@ -18,6 +18,7 @@ function Highlight({
...rest
}: Props) {
let regex;
let index = 0;
if (highlight instanceof RegExp) {
regex = highlight;
} else {
@@ -29,8 +30,10 @@ function Highlight({
return (
<span {...rest}>
{highlight
? replace(text, regex, (tag, index) => (
<Mark key={index}>{processResult ? processResult(tag) : tag}</Mark>
? replace(text, regex, (tag) => (
<Mark key={index++}>
{processResult ? processResult(tag) : tag}
</Mark>
))
: text}
</span>