2

i'm using expo for my android app and trying to make a Picker. I currently have 3 Picker.Items and everytime i click on one of it (to change the current Picker value), it gives me error. I've searched for the fix, read the documentation, etc. but i still can't find my solution to this. Here is my code

state = { value: "" };
  updatePicker = val => {
    this.setState({ value: val });
  };

and below is my syntax inside my app class

<Picker
  selectedValue={this.state.selectedValue}
  onValueChange={updateValue}
>
<Picker.Item key="1" label="Test 1" value="test 1" />
<Picker.Item key="2" label="Test 2" value="test 2" />
<Picker.Item key="3" label="Test 3" value="test 3" />
</Picker>

this somehow gives me this error

_this.setState is not a function. (In '_this.setState({ value: value})', '_this.setState' is undefined)

thank you in advanced

BrianLz
  • 21
  • 1
  • Depending on where the `updatePicker = val => {` code is located in your class you can do: `onValueChange={this.updateValue}` – HMR Sep 14 '19 at 14:48
  • @HMR tried, still gives me same error – BrianLz Sep 15 '19 at 09:39
  • Possible duplicate of [React Native: this.setState is not a function](https://stackoverflow.com/questions/38440925/react-native-this-setstate-is-not-a-function) – HMR Sep 16 '19 at 09:42

0 Answers0