From c5ba9f13896fe345b83aeb87064e1a874dd45911 Mon Sep 17 00:00:00 2001 From: Tom <28008958+taeh98@users.noreply.github.com> Date: Fri, 1 Sep 2023 16:50:04 +0100 Subject: [PATCH] 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 --- README.md | 20 +++++++++++++++----- src/components/Picker.js | 31 ------------------------------- 2 files changed, 15 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 3ae6689..161ba21 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ # React Native Dropdown Picker - - Current npm package version. - +

+ + react-native-dropdown-picker is released under the MIT license. + + + Current npm package version. + +

## Screenshots @@ -19,7 +25,11 @@ The above screenshots are taken from the following example: [https://snack.expo.dev/8mHmLfcZf](https://snack.expo.dev/8mHmLfcZf) -## Documentation +## Usage + +See [the relevant documentation](https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/usage). + +## Further documentation The docs can be read at: [https://hossein-zare.github.io/react-native-dropdown-picker-website](https://hossein-zare.github.io/react-native-dropdown-picker-website). diff --git a/src/components/Picker.js b/src/components/Picker.js index 8549329..eb3bed6 100644 --- a/src/components/Picker.js +++ b/src/components/Picker.js @@ -49,27 +49,6 @@ import RenderListItem from './RenderListItem'; const { height: WINDOW_HEIGHT } = Dimensions.get('window'); -/** - * Find whether two value arrays (value prop and memoryRef.current.value) have the same values. - * === will just check if arrays are the same reference, not if their values are the same. - * @param valueOne first array - * @param valueTwo second array - * @returns boolean representing whether the two values are the same. - */ -function areValueArraysEqual(valueOne, valueTwo) { - if (Array.isArray(valueOne) !== Array.isArray(valueTwo)) return false; - - if (!Array.isArray(valueOne)) return valueOne === valueTwo; - - if (valueOne.length !== valueTwo.length) return false; - - for (let i = 0; i < valueOne.length; i += 1) { - if (valueOne[i] !== valueTwo[i]) return false; - } - - return true; -} - function Picker({ items = [], setItems = () => {}, @@ -1425,16 +1404,6 @@ function Picker({ */ const onPressItem = useCallback( (item, customItem = false) => { - if (!areValueArraysEqual(value, memoryRef.current.value)) { - throw new Error( - `${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( - value, - )} and memoryRef.current.value was: ${JSON.stringify( - memoryRef.current.value, - )}`, - ); - } - // if pressed item was a custom item by the user, add it to the list of items (?) if (customItem !== false) { item.custom = false;