Describe the bug
When i click on the select on Android the application crash.
This is the log from the Android Studio console:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.wtaapp, PID: 4475
com.facebook.react.bridge.NoSuchKeyException: label
at com.facebook.react.bridge.ReadableNativeMap.getNullableValue(ReadableNativeMap.java:137)
at com.facebook.react.bridge.ReadableNativeMap.getNullableValue(ReadableNativeMap.java:141)
at com.facebook.react.bridge.ReadableNativeMap.getString(ReadableNativeMap.java:192)
at com.facebook.react.views.picker.ReactPickerManager$ReactPickerAdapter.getView(ReactPickerManager.java:126)
at com.facebook.react.views.picker.ReactPickerManager$ReactPickerAdapter.getDropDownView(ReactPickerManager.java:112)
at android.widget.Spinner$DropDownAdapter.getDropDownView(Spinner.java:1022)
at android.widget.Spinner$DropDownAdapter.getView(Spinner.java:1018)
at android.widget.Spinner.measureContentWidth(Spinner.java:860)
at android.widget.Spinner$DropdownPopup.computeContentWidth(Spinner.java:1255)
at android.widget.Spinner$DropdownPopup.show(Spinner.java:1281)
at android.widget.Spinner.performClick(Spinner.java:784)
at android.support.v7.widget.AppCompatSpinner.performClick(AppCompatSpinner.java:443)
at android.view.View$PerformClick.run(View.java:24931)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
To Reproduce
This is my configuration:
render() {
let styleShadow = {}
if (this.props.shadow) {
styleShadow = {
shadowColor: config.colors.black,
shadowOffset: { width: 0, height: 3 },
shadowOpacity: 0.15
}
}
const style = [{
paddingLeft: this.props.icon ? 40 : 15,
paddingRight: 15,
paddingTop: 10,
paddingBottom: 10,
backgroundColor: config.colors.white,
borderColor: this.state.borderColor,
borderWidth: 1,
fontFamily: config.fonts.poppins,
borderRadius: 10,
}, styleShadow]
return (
<View style={[{
marginBottom: 15,
position: 'relative'
}]}>
<PickerSelect
style={{
inputAndroid: style,
inputIOS: style,
done: { color: config.colors.red },
placeholder: { color: config.colors.black }
}}
items={this.props.items}
onValueChange={this.props.onChangeText}
placeholder={this.props.placeholder}
value={this.props.value}
useNativeAndroidPickerStyle={false}
doneText="Confirm"
/>
</View>
)
}
Smartphone:
@gregogalante, noticed you closed this issue. Did you find a resolution to this? We're getting the exact same error whenever we pass an empty array of items to the picker. Same details / env as you.
Right now we're working around it by populating optimistically and then loading in the data from the API so the items are never empty.
@gregogalante, noticed you closed this issue. Did you find a resolution to this? We're getting the exact same error whenever we pass an empty array of items to the picker. Same details / env as you.
Right now we're working around it by populating optimistically and then loading in the data from the API so the
itemsare never empty.
My problem was related to the placeholder props. I pass a string as props insthead of an object with same keys like an option object.
I ran into the same issue. @gregogalante's solution fixed my issue.
I was also experiencing the same crash. Similar solution to above. I was already passing in a placeholder object like so -
placeholder={{label: someLabel, value: someValue}}
BUT, I discovered someLabel and someValue were undefined. So I had to ensure that those values were getting thru, and then it worked.
Most helpful comment
My problem was related to the placeholder props. I pass a string as props insthead of an object with same keys like an option object.