Skip to content

Commit c5ba9f1

Browse files
authored
fix: remove unneeded error; also add license badge and usage info to readme (#702)
* removed unneeded error when values aren't equal; testing showed worked anyway * added usage section with link to relevant docs section to README.md * added licence badge to README.md * corrected package name in licence image alt text
1 parent d5116e0 commit c5ba9f1

File tree

2 files changed

+15
-36
lines changed

2 files changed

+15
-36
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# React Native Dropdown Picker
22

3-
<a href="https://www.npmjs.org/package/react-native-dropdown-picker">
4-
<img src="https://img.shields.io/npm/v/react-native-dropdown-picker?color=brightgreen&label=npm%20package"
5-
alt="Current npm package version." />
6-
</a>
3+
<p align="left">
4+
<a href="https://github.com/hossein-zare/react-native-dropdown-picker/blob/dev-5.x/LICENSE">
5+
<img src="https://img.shields.io/badge/license-MIT-blue.svg"
6+
alt="react-native-dropdown-picker is released under the MIT license." />
7+
</a>
8+
<a href="https://www.npmjs.org/package/react-native-dropdown-picker">
9+
<img src="https://img.shields.io/npm/v/react-native-dropdown-picker?color=brightgreen&label=npm%20package"
10+
alt="Current npm package version." />
11+
</a>
12+
</p>
713

814
## Screenshots
915

@@ -19,7 +25,11 @@
1925
The above screenshots are taken from the following
2026
example: [https://snack.expo.dev/8mHmLfcZf](https://snack.expo.dev/8mHmLfcZf)
2127

22-
## Documentation
28+
## Usage
29+
30+
See [the relevant documentation](https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/usage).
31+
32+
## Further documentation
2333

2434
The docs can be read
2535
at: [https://hossein-zare.github.io/react-native-dropdown-picker-website](https://hossein-zare.github.io/react-native-dropdown-picker-website).

src/components/Picker.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,6 @@ import RenderListItem from './RenderListItem';
4949

5050
const { height: WINDOW_HEIGHT } = Dimensions.get('window');
5151

52-
/**
53-
* Find whether two value arrays (value prop and memoryRef.current.value) have the same values.
54-
* === will just check if arrays are the same reference, not if their values are the same.
55-
* @param valueOne first array
56-
* @param valueTwo second array
57-
* @returns boolean representing whether the two values are the same.
58-
*/
59-
function areValueArraysEqual(valueOne, valueTwo) {
60-
if (Array.isArray(valueOne) !== Array.isArray(valueTwo)) return false;
61-
62-
if (!Array.isArray(valueOne)) return valueOne === valueTwo;
63-
64-
if (valueOne.length !== valueTwo.length) return false;
65-
66-
for (let i = 0; i < valueOne.length; i += 1) {
67-
if (valueOne[i] !== valueTwo[i]) return false;
68-
}
69-
70-
return true;
71-
}
72-
7352
function Picker({
7453
items = [],
7554
setItems = () => {},
@@ -1425,16 +1404,6 @@ function Picker({
14251404
*/
14261405
const onPressItem = useCallback(
14271406
(item, customItem = false) => {
1428-
if (!areValueArraysEqual(value, memoryRef.current.value)) {
1429-
throw new Error(
1430-
`${new Date().toString()} The arrays of the value prop and memoryRef.current.value were not equal in the callback for when items are pressed in the Picker component. value was: ${JSON.stringify(
1431-
value,
1432-
)} and memoryRef.current.value was: ${JSON.stringify(
1433-
memoryRef.current.value,
1434-
)}`,
1435-
);
1436-
}
1437-
14381407
// if pressed item was a custom item by the user, add it to the list of items (?)
14391408
if (customItem !== false) {
14401409
item.custom = false;

0 commit comments

Comments
 (0)