question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Picker - undefined is not an object (evaluating 'this.props.children[position].props)

See original GitHub issue

I am encountering a weird behaviour when using Picker.

I use a Picker as follows :

<Picker
  mode="dropdown"
  style={styles.pickerField}
  selectedValue={this.state.dayAndTime}
  onValueChange={(text) => this.setState({ dayAndTime: text })}
>
  <Picker.Item label="Le 5/07 à 15H" value="0" key="0" />
</Picker>

When the screen displaying this picker is loaded, I got an error screen saying (cf. screenshot below) : undefined is not an object (evaluating 'this.props.children[position].props)

From what I gathered, my problem come from line 106 of Libraries/Components/Picker/PickerAndroid.android.js, it seems that onValueChange creates it, so I removed it, and I don’t have the error anymore.

I use react-native 0.31.0, I use an android api 23 virtual device with genymotion.

Is there something I am missing ?

pickererror

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
luoyjxcommented, Jun 24, 2017

so, i found a resolution that we can create an array contains blank Item before use it.

render() {
    const pickerItems = this.props.depts.map(dept => {
      return (
        <Picker.Item key={'d' + dept.id} label={dept.name} value={dept.id} />
      )
    })

    pickerItems.unshift(<Picker.Item key="d0" label="选择部门" value="" />)

    return (
        <Picker
             selectedValue={this.state.deptId}
             onValueChange={value => this.setState({ deptId: value })}>
             {pickerItems}                  
        </Picker>
    )
}
1reaction
willoughbycommented, Sep 22, 2016

Having the same issue as @alexsotocx, However if you add to static items, you can select them with no error, but any items dynamically added in a map throw the error reported

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native - Picker - undefined is not an object (evaluating ...
I had a similar issue but it was using an Item component + an array. ... <Picker style={styles.picker} mode="dropdown" { ...props }> <Picker...
Read more >
react-native - Picker - undefined is not an object (evaluating ...
Coding example for the question react-native - Picker - undefined is not an object (evaluating 'this.props.children[position].props)-React Native.
Read more >
ERROR TypeError: undefined is not an object (evaluating ...
Ever encountered this error → ERROR TypeError: undefined is not an object (evaluating '_this.props.navigation.navigate') whilst working hard on your project?
Read more >
react-native - Picker - undefined is not an object ... - Reddit
react-native - Picker - undefined is not an object (evaluating 'this.props.children[position].props). r/reactnative - react-native - Picker ...
Read more >
React Native. undefined is not an object (evaluating '_this ...
props.updateCellsBatchingPeriod'). Hi everybody, I have a react-native app created with RN CLI, using react-native 0.63, I'm ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found