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 :child.props.value

See original GitHub issue

I am trying to return Picker.Item from an array but I face the following error:

undefined is not an object :child.props.value <Picker style={{ paddingLeft: 100, width:(Platform.OS === 'ios') ? undefined : 120 }}
iosHeader="Selecy"
mode="dropdown"
selectedValue="0"
inLineLabel={true}>
<Picker.Item label="Item 0" value="0" />
{this.props.ItemList.map((member,key)=>{
<Picker.Item label={member.props} value={member.value} />
})
}
</Picker>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:27 (3 by maintainers)

github_iconTop GitHub Comments

14reactions
xanderdeseyncommented, Jul 29, 2017

We found the solution… the bug is quite incredible really.

We are using ImmutableJS for our redux state. this.props.values is an immutable list. When you go and look at the source code of Picker.ios.js, you see that it is using lodash’s find function. Apparently, they can’t handle an immutable list even though it works throughout the rest of React Native.

The (ugly) solution is thus: { this.props.values.toArray().map( value => (<Picker.Item key={value} label={value} value={value} />) ) }

8reactions
Suraj-Tiwaricommented, Jan 4, 2018

Recently I’ve faced the same issue, This might be a less ugly solution This is hapenning because of this

<Picker.Item label="Item 0" value="0" /> /// **<- Issue is here due to this hard coded Item** 
{this.props.ItemList.map((member,key)=>{<Picker.Item label={member.props} value{member.value} />
})
render() {
  return (
    <Picker mode='dropdown' selectedValue={selectedValue} onValueChange={onValueChange} >
      { make_list(['pass','your','desire','list']) }
    </Picker>
  )}
function make_list(list){
        d = list.map((data,i) => {
            return (
                <Picker.Item label={data} value={i}/>
            )
        })
       // i did this because no need in ios :P 
        if(Platform.OS === 'android'){
            d.unshift(<Picker.Item label="Select" />)
        }
        return d;
      //and that's how you are ready to go, because this issue isn't fixed yet (checked on 28-Dec-2017)
 }

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Undefined is not an object (evaluating 'child.props.value ...
The problem was with react-native version. it's not working in 0.48, but working fine in 0.49. one more thing is Picker is not...
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 >
Controller | React Hook Form - Simple React forms validation
undefined is not a valid value. If your form will invoke reset with default values, you will need to provide useForm with defaultValues...
Read more >
How to use react-native-picker-select - LogRocket Blog
Each item is an object with a label and value property. The items appear as options rendered to the user when the select...
Read more >
Forms in React Native, The right way
Updated 06/04/2021 : adding select input and date picker Handling ... or return the child without creating a new one if it's not...
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