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

Placeholder not displaying when using state var for the label. #622

Open
bitdelve opened this issue Sep 10, 2024 · 0 comments
Open

Placeholder not displaying when using state var for the label. #622

bitdelve opened this issue Sep 10, 2024 · 0 comments

Comments

@bitdelve
Copy link

bitdelve commented Sep 10, 2024

Describe the bug

When I set the label of the placeholder with a state variable it doesn't display. It will show the correct State name when I select the picker, but doesn't show the value of the placeholder until I select the placeholder, as seen in the attached screenshot. (Shows Alabama Twice) I have tried to use itemKey and value props as well, but that doesn't work either.

To Reproduce

Here is my code creating the RNPickerSelect



<RNPickerSelect
  style={pickerSelectStyles}
  onValueChange={(value, index) => {this.onSelectState(this.state.itemsState[index === 0 ? 0 : index - 1], 
  index - 1)}}                               
  items = {stateOptions}
  useNativeAndroidPickerStyle = {false}
  placeholder={{value: '', label: this.state.State}}
  Icon={() => {
    return <Icon size={15} color='black' name='chevron-down' style={{paddingTop: 2}}></Icon>;}
  }
/>

Here is my style:

const pickerSelectStyles = StyleSheet.create({
  inputIOS: {
    fontSize: 14,
    textAlign: 'left',
    paddingEnd: 25,
    paddingStart: 5,
    color: '#0B254B',
    borderRadius: 4,
    height: 40,
  },
  inputAndroid: {
    fontSize: 14,
    textAlign: 'left',
    paddingEnd: 25,
    paddingStart: 5,
    color: '#0B254B',
    borderRadius: 4,
    height: 40,
  },
  iconContainer: {top: 10, right: 5},
  placeholder: {
    color: 'black'
  }
})

Expected behavior

I expect the placehold to show the value in the state variable

Screenshots

Screenshot 2024-09-10 at 8 18 18 AM

Additional details

iPhone simulator
RN version 0.74.3

Reproduction and/or code sample

I am unable to provide a snack as this is currently in production, and for the company I work for.

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

No branches or pull requests

1 participant