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
This PR addresses issue #[ISSUE_NUMBER] (Replace with actual issue number if applicable).
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
[x] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[x] Breaking change (fix or feature that would cause existing functionality to change)
[x] Documentation update
Checklist
[x] My code follows the code style of this project.
[x] My change requires a change to the documentation.
[x] I have updated the documentation accordingly.
[x] I have read the CONTRIBUTING document.
[x] I have added tests to cover my changes.
[x] All new and existing tests passed.
Additional Notes
Please review the changes and let me know if there are any adjustments needed. Thank you!
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!