react-native-picker-select icon indicating copy to clipboard operation
react-native-picker-select copied to clipboard

Allow for selectedItem state change for placeholder

Open cchalfan1 opened this issue 5 years ago • 0 comments

I have not seen any issues with this, however I am probably not using all of the capabilities of this package.

I was having an issue where the placeholder would not change, even though the state for the placeholder of the parent component was changing. These changing props were not being seen because a condition a few lines above these changes were returning false when they should have been true.

Specifically:

const selectedItemChanged =
            !isEqual(nextProps.value, undefined) && !isEqual(prevState.selectedItem, selectedItem); // <= kept returning false because nextProps.value always seems to be undefined

        if (itemsChanged || selectedItemChanged) {
            if (selectedItemChanged) {
                nextProps.onValueChange(selectedItem.value, idx);
            }

            return {
                ...(itemsChanged ? { items } : {}),
                selectedItem
                // ...(selectedItemChanged ? { selectedItem } : {}),
            };
        }

At least, I figured this was worth the review.

Cheers

cchalfan1 avatar Jul 08 '20 15:07 cchalfan1