mirror of
https://github.com/zhigang1992/devhub.git
synced 2026-06-18 12:14:42 +08:00
Fix warning about duplicated key
This commit is contained in:
@@ -22,27 +22,20 @@ export default class EventCards extends PureComponent<
|
||||
EventCardsState
|
||||
> {
|
||||
keyExtractor(event: IEnhancedGitHubEvent) {
|
||||
return `${event.id}`
|
||||
return `event-card-${event.id}`
|
||||
}
|
||||
|
||||
renderItem = ({ item: event }: { item: IEnhancedGitHubEvent }) => {
|
||||
if (this.props.swipeable) {
|
||||
return (
|
||||
<SwipeableEventCard
|
||||
key={`event-card-${event.id}`}
|
||||
event={event}
|
||||
repoIsKnown={this.props.repoIsKnown}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<EventCard
|
||||
key={`event-card-${event.id}`}
|
||||
event={event}
|
||||
repoIsKnown={this.props.repoIsKnown}
|
||||
/>
|
||||
)
|
||||
return <EventCard event={event} repoIsKnown={this.props.repoIsKnown} />
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -21,25 +21,15 @@ export default class NotificationCards extends PureComponent<
|
||||
NotificationCardsState
|
||||
> {
|
||||
keyExtractor(notification: IGitHubNotification) {
|
||||
return `${notification.id}`
|
||||
return `notification-card-${notification.id}`
|
||||
}
|
||||
|
||||
renderItem = ({ item: notification }: { item: IGitHubNotification }) => {
|
||||
if (this.props.swipeable) {
|
||||
return (
|
||||
<SwipeableNotificationCard
|
||||
key={`notification-card-${notification.id}`}
|
||||
notification={notification}
|
||||
/>
|
||||
)
|
||||
return <SwipeableNotificationCard notification={notification} />
|
||||
}
|
||||
|
||||
return (
|
||||
<NotificationCard
|
||||
key={`notification-card-${notification.id}`}
|
||||
notification={notification}
|
||||
/>
|
||||
)
|
||||
return <NotificationCard notification={notification} />
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -62,7 +62,10 @@ export default class EventCardsContainer extends PureComponent<
|
||||
)
|
||||
const events: IGitHubEvent[] = await response.json()
|
||||
if (Array.isArray(events)) {
|
||||
const orderedEvents = _.orderBy(events, ['updated_at'], ['desc'])
|
||||
const orderedEvents = _(events)
|
||||
.uniqBy('id')
|
||||
.orderBy(['updated_at'], ['desc'])
|
||||
.value()
|
||||
const mergedEvents = mergeSimilarEvent(orderedEvents)
|
||||
this.setState({ events: mergedEvents })
|
||||
}
|
||||
|
||||
@@ -60,11 +60,10 @@ export default class NotificationCardsContainer extends PureComponent<
|
||||
const notifications: IGitHubNotification[] = await response.json()
|
||||
if (Array.isArray(notifications)) {
|
||||
this.setState({
|
||||
notifications: _.orderBy(
|
||||
notifications,
|
||||
['unread', 'updated_at'],
|
||||
['desc', 'desc'],
|
||||
),
|
||||
notifications: _(notifications)
|
||||
.uniqBy('id')
|
||||
.orderBy(['unread', 'updated_at'], ['desc', 'desc'])
|
||||
.value(),
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user