From 8167879f87121f3efc9f4d29733da95bb206c960 Mon Sep 17 00:00:00 2001 From: Hossein Zare Date: Wed, 12 May 2021 15:12:29 +0430 Subject: [PATCH 1/2] Rename key prom to itemKey. --- index.d.ts | 2 +- src/components/Picker.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index f7b88251..dec12ddb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -177,7 +177,7 @@ declare module "react-native-dropdown-picker" { multiple?: boolean; multipleText?: string; mode?: ModeType; - key?: string; + itemKey?: string; maxHeight?: number; renderBadgeItem?: (props: RenderBadgeItemPropsInterface) => JSX.Element; renderListItem?: (props: RenderListItemPropsInterface) => JSX.Element; diff --git a/src/components/Picker.js b/src/components/Picker.js index 68533bff..f81368d8 100644 --- a/src/components/Picker.js +++ b/src/components/Picker.js @@ -102,7 +102,7 @@ function Picker({ multiple = false, multipleText = null, mode = MODE.DEFAULT, - key = null, + itemKey = null, maxHeight = 200, renderBadgeItem = null, renderListItem = null, @@ -873,18 +873,18 @@ function Picker({ * The badge key. * @returns {string} */ - const _key = useMemo(() => { - if (key === null) + const _itemKey = useMemo(() => { + if (itemKey === null) return _schema.value; - return key; - }, [key, _schema]); + return itemKey; + }, [itemKey, _schema]); /** * The key extractor. * @returns {string} */ - const keyExtractor = useCallback((item) => `${item[_key]}`, [_key]); + const keyExtractor = useCallback((item) => `${item[_itemKey]}`, [_itemKey]); /** * The badge separator style. @@ -1482,7 +1482,7 @@ function Picker({ {_items.map((item, index) => { return ( - + {index > 0 && ItemSeparatorComponent()} {__renderListItem({item})} @@ -1491,7 +1491,7 @@ function Picker({ {_items.length === 0 && _ListEmptyComponent()} ); - }, [renderListItem, __renderListItem, _key, scrollViewProps, _ListEmptyComponent]); + }, [renderListItem, __renderListItem, _itemKey, scrollViewProps, _ListEmptyComponent]); /** * The dropdown modal component. From 8469af04452c7f6cc86ac64bac0830c6308011b5 Mon Sep 17 00:00:00 2001 From: Hossein Zare Date: Wed, 12 May 2021 15:13:07 +0430 Subject: [PATCH 2/2] v5.1.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed8d3404..ca27bece 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-dropdown-picker", - "version": "5.1.11", + "version": "5.1.12", "description": "A single / multiple, categorizable, customizable, localizable and searchable item picker (drop-down) component for react native which supports both Android & iOS.", "keywords": [ "picker",