Skip to content

Commit c3146e3

Browse files
committed
use iconRenderer as Icon component
1 parent f44dad9 commit c3146e3

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

lib/components/ItemIcon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
33
import { Image } from 'react-native'
4-
import Icon from 'react-native-vector-icons/MaterialIcons'
4+
// import Icon from 'react-native-vector-icons/MaterialIcons'
55

6-
const ItemIcon = ({ icon, iconKey, itemIconStyle }) => {
6+
const ItemIcon = ({ iconRenderer: Icon, icon, iconKey, itemIconStyle }) => {
77
return (
88
typeof icon === 'object' || typeof icon === 'number' ?
99
<Image

lib/components/RowItem.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class RowItem extends Component {
3333
}
3434

3535
shouldComponentUpdate(nextProps, nextState) {
36-
3736
if (nextProps.selectedItems !== this.props.selectedItems) {
3837
if (
3938
this.props.selectedItems.includes(this.props.item[this.props.uniqueKey]) &&
@@ -70,7 +69,6 @@ class RowItem extends Component {
7069
) {
7170
return true
7271
}
73-
7472
}
7573

7674
if (this.props.searchTerm !== nextProps.searchTerm) {
@@ -172,7 +170,11 @@ class RowItem extends Component {
172170
)
173171
_renderSelectedIcon = () => {
174172
const {
175-
item, selectedIconComponent, mergedColors, unselectedIconComponent,
173+
item,
174+
selectedIconComponent,
175+
mergedColors,
176+
unselectedIconComponent,
177+
iconRenderer: Icon,
176178
} = this.props
177179
return this._itemSelected(item)
178180
? callIfFunction(selectedIconComponent) || (
@@ -205,6 +207,7 @@ class RowItem extends Component {
205207
displayKey,
206208
selectedItems,
207209
iconKey,
210+
iconRenderer: Icon,
208211
} = this.props
209212
const hasDropDown = item[subKey] && item[subKey].length > 0 && showDropDowns
210213

@@ -235,7 +238,12 @@ class RowItem extends Component {
235238
>
236239
{selectedIconOnLeft && this._renderSelectedIcon()}
237240
{iconKey && item[iconKey] && (
238-
<ItemIcon iconKey={iconKey} icon={item[iconKey]} style={mergedStyles.itemIconStyle} />
241+
<ItemIcon
242+
iconRenderer={Icon}
243+
iconKey={iconKey}
244+
icon={item[iconKey]}
245+
style={mergedStyles.itemIconStyle}
246+
/>
239247
)}
240248
<Text
241249
numberOfLines={itemNumberOfLines}

lib/components/RowSubItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { Component } from 'react'
22
import PropTypes from 'prop-types'
33
import { View, TouchableOpacity, Text, Image } from 'react-native'
4-
import Icon from 'react-native-vector-icons/MaterialIcons'
54
import ItemIcon from './ItemIcon'
65
import { callIfFunction } from '../helpers'
76

@@ -54,6 +53,7 @@ class RowSubItem extends Component {
5453
highlightedChildren,
5554
uniqueKey,
5655
subItem,
56+
iconRenderer: Icon,
5757
} = this.props
5858
const highlightChild = !selectChildren && highlightedChildren.includes(subItem[uniqueKey])
5959
const itemSelected = this._itemSelected()

0 commit comments

Comments
 (0)