Skip to content

Commit

Permalink
Add fix for crash caused by invalid data being passed to ScrollCard (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gulci authored Jun 19, 2018
1 parent 92120c4 commit fa3fc56
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/views/common/ScrollCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ElevatedView from 'react-native-elevated-view'

import CardHeader from './CardHeader'
import CardMenu from './CardMenu'
import { trackException } from '../../util/logger'
import css from '../../styles/css'
import LAYOUT from '../../styles/LayoutConstants'

Expand Down Expand Up @@ -54,7 +55,14 @@ class ScrollCard extends React.Component {
scrollEventThrottle={0}
data={this.props.scrollData}
enableEmptySections={true}
keyExtractor={(listItem, index) => (listItem.id.toString() + index)}
keyExtractor={(listItem, index) => {
if (listItem.id) return listItem.id.toString() + index
else {
const error = new Error('Invalid ScrollCard list item')
trackException(error, listItem)
return index
}
}}
renderItem={this.props.renderItem}
/>
)
Expand Down

0 comments on commit fa3fc56

Please sign in to comment.