NativeBase: Picker : undefined is not an object :child.props.value
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>
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 27 (3 by maintainers)
We found the solution… the bug is quite incredible really.
We are using ImmutableJS for our redux state.
this.props.valuesis an immutable list. When you go and look at the source code of Picker.ios.js, you see that it is using lodash’sfindfunction. 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} />) ) }Recently I’ve faced the same issue, This might be a less ugly solution This is hapenning because of this
I guess that will happen in the following cases:
A) rendering just one Ref: https://github.com/GeekyAnts/NativeBase/issues/921
B) rendering one and an array of items
C) not returning element in callback
Same issue with 2.13.4, only on iOS in my case, Android works fine.
We are running into the same problem here, while simply using map:
Anyone found a solution yet?
Why is this closed I’m still facing the same issue here
@ap050492 the map function misses return statement.
Change this
to
or
Fixed with 2.7.1
@shivrajkumar This does appear to be a NativeBase bug - this type of example from @horiuchie works fine for us in React Native on Android but breaks in NativeBase: