Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for itemKey property in RNPickerSelect component #586

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

athul-22
Copy link

@athul-22 athul-22 commented Jun 9, 2024

Description

This PR enhances the RNPickerSelect component by adding support for the itemKey property. This allows for better handling of items with identical values but unique keys, providing a more robust selection mechanism. The changes include updates to the prop types, the constructor, and the getSelectedItem and componentDidUpdate methods to utilize itemKey correctly.

Changes Made

  • Added itemKey prop to RNPickerSelect PropTypes.
  • Updated the constructor to handle itemKey.
  • Modified getSelectedItem method to use itemKey for item selection.
  • Updated componentDidUpdate to check for changes in itemKey and value.

Related Issue

Motivation and Context

The itemKey property ensures that items with identical values can be uniquely identified and selected. This is particularly useful in scenarios where the same value might be associated with different keys, improving the flexibility and reliability of the component.

How Has This Been Tested?

  • Manually tested on both iOS and Android platforms.
  • Verified that the correct item is selected when using itemKey.
  • Ensured backward compatibility with existing usage of the component without itemKey.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Additional Notes

Please review the changes and let me know if there are any adjustments needed. Thank you!

remarkablemark

This comment was marked as resolved.

@athul-22

This comment was marked as resolved.

@remarkablemark

This comment was marked as resolved.

@athul-22

This comment was marked as resolved.

Copy link
Contributor

@remarkablemark remarkablemark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint failures:

Run yarn lint
yarn run v1.22.22
$ eslint "src/**/*.{js,jsx,ts,tsx}"

/home/runner/work/react-native-picker-select/react-native-picker-select/src/index.js
Error:   161:1   error  This line has a length of 103. Maximum allowed is 100                                                                                                                                                               max-len
Error:   169:7   error  Replace `(!isEqual(this.props.itemKey,·prevProps.itemKey)` with `!isEqual(this.props.itemKey,·prevProps.itemKey`                                                                                                    prettier/prettier
Error:   380:28  error  Replace `⏎················?·[defaultStyles.doneDepressed,·style.doneDepressed]⏎···············` with `·?·[defaultStyles.doneDepressed,·style.doneDepressed]`                                                        prettier/prettier
Error:   392:30  error  Replace `⏎··················?·[defaultStyles.doneTextDepressed,·style.doneTextDepressed]⏎·················` with `·?·[defaultStyles.doneTextDepressed,·style.doneTextDepressed]`                                    prettier/prettier
Error:   419:27  error  Replace `·Platform.OS·===·'android'·&&·fixAndroidTouchableBug⏎······?·{·height:·0,·width:·0,·flex:·1·}⏎·····` with `⏎······Platform.OS·===·'android'·&&·fixAndroidTouchableBug·?·{·height:·0,·width:·0,·flex:·1·}`  prettier/prettier
Error:   427:13  error  Expected no linebreak before this expression                                                                                                                                                                        implicit-arrow-linebreak
Error:   431:11  error  Unexpected newline before ')'                                                                                                                                                                                       function-paren-newline
Error:   453:28  error  'orientation' is assigned a value but never used                                                                                                                                                                    no-unused-vars
Error:   579:42  error  'fixAndroidTouchableBug' is assigned a value but never used                                                                                                                                                         no-unused-vars

✖ 9 problems (9 errors, 0 warnings)
  6 errors and 0 warnings potentially fixable with the `--fix` option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants