I have this picker:
<Picker
style={{ width: "100%" }}
mode="dropdown"
selectedValue={move.client}
onValueChange={this.handleChange("client")}
>
{this.state.clients !== "" ? (
this.state.clients.map(client => {
<Picker.Item label={client.name} value={client.id} />;
})
) : (
<Picker.Item label="Loading..." value="0" />
)}
</Picker>
I can't make the Picker.items to be the array that I want. It works just like that in React JS, but i can't make it work here.
And this is how I get the Clients array from my DB:
componentDidMount() {
axios
.get(`${API_URL}/clients`)
.then(response => {
this.setState({ clients: response.data });
})
.catch(error => console.log(error));
}
I get this error
TypeError: Cannot read property 'props' of null
It seems that it renders the picker, but when I get the data from my DB it just crashes and I get this error. I just can't find what I'm doing wrong...