Fix missing key warning

This commit is contained in:
Bruno Lemos
2019-03-23 02:59:02 -03:00
parent a2fb52d4aa
commit 232bee1d30
4 changed files with 9 additions and 3 deletions

View File

@@ -90,6 +90,7 @@ export const CommentRow = React.memo((props: CommentRowProps) => {
]}
>
{parseTextWithEmojisToReactComponents(body, {
key: `comment-text-${body}`,
imageProps: {
style: {
width: 14,

View File

@@ -122,6 +122,7 @@ export function Label(props: LabelProps) {
)}
{typeof children === 'string'
? parseTextWithEmojisToReactComponents(children, {
key: `label-text-${children}`,
imageProps: {
style: {
width: small ? 10 : 11,

View File

@@ -269,6 +269,7 @@ export const AdvancedSettingsModal = React.memo(
installation.htmlUrl
) && (
<View
key={`github-installation-${installation.id}`}
style={{
flexDirection: 'row',
alignItems: 'center',

View File

@@ -1,6 +1,6 @@
import { Omit } from '@devhub/core'
import _ from 'lodash'
import React from 'react'
import React, { Fragment } from 'react'
import { Image, ImageProps } from 'react-native'
const emojis = {
@@ -1538,10 +1538,11 @@ function surrogatePairToCodepoint(lead: number, trail: number) {
}
export interface EmojiParseOptions {
after?: React.ReactNode
alt?: string
before?: React.ReactNode
after?: React.ReactNode
imageProps?: Omit<ImageProps, 'source'>
key: string
}
function getComponent(
@@ -1625,5 +1626,7 @@ export function parseTextWithEmojisToReactComponents(
if (typeof item !== 'string') return item
return parseTextWithEmojisToReactComponents_2(item, options)
}),
)
).map((item, index) => (
<Fragment key={`${options.key}-${index}`}>{item}</Fragment>
))
}