Skip to content

Commit

Permalink
Fix missing key warning
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolemos committed Mar 23, 2019
1 parent a2fb52d commit 232bee1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const CommentRow = React.memo((props: CommentRowProps) => {
]}
>
{parseTextWithEmojisToReactComponents(body, {
key: `comment-text-${body}`,
imageProps: {
style: {
width: 14,
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/components/common/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export function Label(props: LabelProps) {
)}
{typeof children === 'string'
? parseTextWithEmojisToReactComponents(children, {
key: `label-text-${children}`,
imageProps: {
style: {
width: small ? 10 : 11,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export const AdvancedSettingsModal = React.memo(
installation.htmlUrl
) && (
<View
key={`github-installation-${installation.id}`}
style={{
flexDirection: 'row',
alignItems: 'center',
Expand Down
9 changes: 6 additions & 3 deletions packages/components/src/utils/helpers/github/emojis.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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>
))
}

0 comments on commit 232bee1

Please sign in to comment.