Added support for itemKey property in RNPickerSelect component #586
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
RNPickerSelect
component by adding support for theitemKey
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 thegetSelectedItem
andcomponentDidUpdate
methods to utilizeitemKey
correctly.Changes Made
itemKey
prop toRNPickerSelect
PropTypes.constructor
to handleitemKey
.getSelectedItem
method to useitemKey
for item selection.componentDidUpdate
to check for changes initemKey
andvalue
.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?
itemKey
.itemKey
.Types of changes
Checklist
Additional Notes
Please review the changes and let me know if there are any adjustments needed. Thank you!