Reputation: 471
I'm trying to convert a react app to react native.
For my picker, I am able to show the values, but when I click on a value, I get a TypeError: undefined is not an object (evaluating 'e.target.value'
. I know e.target.value
is not correct, but what value should it be?
const handleDiceTypeInput = e => {
setDiceType(e.target.value);
};
<Picker
selectedValue={diceType}
style={{height: 50, width: 100}}
onValueChange={handleDiceTypeInput}
>
<Picker.Item label="" value="" />
<Picker.Item label="D2" value="2" />
<Picker.Item label="D4" value="4" />
</Picker>
Upvotes: 0
Views: 438
Reputation: 251
See the Picker
documentation. Change it to
const handleDiceTypeInput = (inputValue) => {
setDiceType(inputValue);
};
Upvotes: 1