Skip to content

Commit

Permalink
fix: remove unneeded error; also add license badge and usage info to …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
taeh98 authored Sep 1, 2023
1 parent d5116e0 commit c5ba9f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# React Native Dropdown Picker

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

## Screenshots

Expand All @@ -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).
Expand Down
31 changes: 0 additions & 31 deletions src/components/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {},
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c5ba9f1

Please sign in to comment.