Reputation:
I am trying out picker in my react native project and this example i took directly from the react native docs
<CardItem>
<Item floatingLabel>
<Label>Airtime Amount</Label>
<Picker selectedValue={this.state.language} onValueChange={(lang) => this.setState({language: lang})}> <Picker.Item label="Java" value="java" /> <Picker.Item label="JavaScript" value="js" /></Picker>
</Item>
</CardItem>
This is the source http://facebook.github.io/react-native/docs/picker.html
I get the error
null is not an object (evaluating 'this.state.language')
How can i correct this. render
My class starts like this
class Form extends Component {
static propTypes = {
openDrawer: React.PropTypes.func,
}
....
Upvotes: 1
Views: 490
Reputation: 1236
You need to creat the language and give a value
constructor(props) {
super();
this.state = {
language: 'english', // or language: '',
}
}
Upvotes: 1