Added support for itemKey property in RNPickerSelect component#586
Open
athul-22 wants to merge 2 commits intolawnstarter:masterfrom
Open
Added support for itemKey property in RNPickerSelect component#586athul-22 wants to merge 2 commits intolawnstarter:masterfrom
athul-22 wants to merge 2 commits intolawnstarter:masterfrom
Conversation
Closed
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
remarkablemark
suggested changes
Jul 26, 2024
Contributor
remarkablemark
left a comment
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR enhances the
RNPickerSelectcomponent by adding support for theitemKeyproperty. 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 thegetSelectedItemandcomponentDidUpdatemethods to utilizeitemKeycorrectly.Changes Made
itemKeyprop toRNPickerSelectPropTypes.constructorto handleitemKey.getSelectedItemmethod to useitemKeyfor item selection.componentDidUpdateto check for changes initemKeyandvalue.Related Issue
Motivation and Context
The
itemKeyproperty 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?
itemKey.itemKey.Types of changes
Checklist
Additional Notes
Please review the changes and let me know if there are any adjustments needed. Thank you!