Skip to content

Commit 20bb742

Browse files
committed
fix already declared variable errors
1 parent 9d4d237 commit 20bb742

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/components/Picker.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ function Picker({
275275

276276
if (itemIndex === -1) {
277277
const item = items.find(
278-
(item) => item[ITEM_SCHEMA.value] === currentValue,
278+
(i) => i[ITEM_SCHEMA.value] === currentValue,
279279
);
280280

281281
if (item) {
@@ -294,7 +294,7 @@ function Picker({
294294
const state = [];
295295

296296
if (value !== null) {
297-
const item = items.find((item) => item[ITEM_SCHEMA.value] === value);
297+
const item = items.find((i) => i[ITEM_SCHEMA.value] === value);
298298

299299
if (item) {
300300
state.push(item);
@@ -398,7 +398,7 @@ function Picker({
398398
* @returns {object}
399399
*/
400400
const sortedItems = useMemo(() => {
401-
const sortedItems = items.filter(
401+
const _sortedItems = items.filter(
402402
(item) =>
403403
item[ITEM_SCHEMA.parent] === undefined ||
404404
item[ITEM_SCHEMA.parent] === null,
@@ -410,18 +410,18 @@ function Picker({
410410
);
411411

412412
children.forEach((child) => {
413-
const index = sortedItems.findIndex(
413+
const index = _sortedItems.findIndex(
414414
(item) =>
415415
item[ITEM_SCHEMA.parent] === child[ITEM_SCHEMA.parent] ||
416416
item[ITEM_SCHEMA.value] === child[ITEM_SCHEMA.parent],
417417
);
418418

419419
if (index > -1) {
420-
sortedItems.splice(index + 1, 0, child);
420+
_sortedItems.splice(index + 1, 0, child);
421421
}
422422
});
423423

424-
return sortedItems;
424+
return _sortedItems;
425425
}, [items, ITEM_SCHEMA]);
426426

427427
/**
@@ -438,22 +438,22 @@ function Picker({
438438
)
439439
return;
440440

441-
const value = isArray
441+
const currentValue = isArray
442442
? memoryRef.current.value[0]
443443
: memoryRef.current.value;
444444

445445
if (
446446
scrollViewRef.current &&
447-
Object.prototype.hasOwnProperty.call(itemPositionsRef.current,value)
447+
Object.prototype.hasOwnProperty.call(itemPositionsRef.current,currentValue)
448448
) {
449449
scrollViewRef.current?.scrollTo?.({
450450
x: 0,
451-
y: itemPositionsRef.current[value],
451+
y: itemPositionsRef.current[currentValue],
452452
animated: true,
453453
});
454454
} else {
455455
const index = sortedItems.findIndex(
456-
(item) => item[ITEM_SCHEMA.value] === value,
456+
(item) => item[ITEM_SCHEMA.value] === currentValue,
457457
);
458458

459459
if (index > -1)
@@ -481,7 +481,7 @@ function Picker({
481481
* @returns {object}
482482
*/
483483
const stickyHeaderIndices = useMemo(() => {
484-
const stickyHeaderIndices = [];
484+
const _stickyHeaderIndices = [];
485485
if (stickyHeader) {
486486
const parents = sortedItems.filter(
487487
(item) =>
@@ -492,10 +492,10 @@ function Picker({
492492
const index = sortedItems.findIndex(
493493
(item) => item[ITEM_SCHEMA.value] === parent[ITEM_SCHEMA.value],
494494
);
495-
if (index > -1) stickyHeaderIndices.push(index);
495+
if (index > -1) _stickyHeaderIndices.push(index);
496496
});
497497
}
498-
return stickyHeaderIndices;
498+
return _stickyHeaderIndices;
499499
}, [stickyHeader, sortedItems]);
500500

501501
/**
@@ -727,10 +727,10 @@ function Picker({
727727
);
728728
const size = y + maxHeight + pickerHeight + bottomOffset;
729729

730-
const direction = size < WINDOW_HEIGHT ? 'top' : 'bottom';
730+
const currentDirection = size < WINDOW_HEIGHT ? 'top' : 'bottom';
731731

732-
onDirectionChanged(direction);
733-
setDirection(direction);
732+
onDirectionChanged(currentDirection);
733+
setDirection(currentDirection);
734734
}
735735

736736
onPressToggle();
@@ -1230,11 +1230,11 @@ function Picker({
12301230
* @returns {JSX.Element}
12311231
*/
12321232
const ExtendableBadgeContainer = useCallback(
1233-
({ selectedItems }) => {
1234-
if (selectedItems.length > 0) {
1233+
({ badgeContainerSelectedItems }) => {
1234+
if (badgeContainerSelectedItems.length > 0) {
12351235
return (
12361236
<View style={extendableBadgeContainerStyle}>
1237-
{selectedItems.map((item, index) => (
1237+
{badgeContainerSelectedItems.map((item, index) => (
12381238
<View key={index} style={extendableBadgeItemContainerStyle}>
12391239
<__renderBadge item={item} index={index} />
12401240
</View>
@@ -1258,7 +1258,7 @@ function Picker({
12581258
*/
12591259
const BadgeBodyComponent = useMemo(() => {
12601260
if (extendableBadgeContainer) {
1261-
return <ExtendableBadgeContainer selectedItems={selectedItems} />;
1261+
return <ExtendableBadgeContainer badgeContainerSelectedItems={selectedItems} />;
12621262
}
12631263

12641264
return (
@@ -1672,9 +1672,9 @@ function Picker({
16721672
* @param {string|number|boolean} value
16731673
* @param {number} y
16741674
*/
1675-
const setItemPosition = useCallback((value, y) => {
1675+
const setItemPosition = useCallback((itemValue, y) => {
16761676
if (autoScroll && listMode === LIST_MODE.SCROLLVIEW)
1677-
itemPositionsRef.current[value] = y;
1677+
itemPositionsRef.current[itemValue] = y;
16781678
}, []);
16791679

16801680
/**

0 commit comments

Comments
 (0)