Failed prop type: Invalid prop children of type object supplied to IGNORE
Description
When using the Picker component with prop useNativePicker, I encounter the warning:
Warning: Failed prop type: Invalid prop
childrenof typeobjectsupplied toIGNORE, expectedarray.
In addition, when a value is selected, reopening the Picker does not show the value as selected, it shows the beginning of the options.
Related to
- [X] Components
- [ ] Demo
- [ ] Docs
- [ ] Typings
Steps to reproduce
Modifying/simplifying the example from https://github.com/wix/react-native-ui-lib/issues/1749#issuecomment-1077389451 with useNativePicker prop as true
import React, { useState, useMemo, useCallback } from "react";
import { SafeAreaView } from "react-native";
import { View, Picker } from "react-native-ui-lib";
const itemsFromSomewhere = ["a", "b", "c", "d"];
export default function App() {
const [value, setValue] = useState("a");
const items = useMemo(
() => {
return itemsFromSomewhere.map(m => ({
value: m,
label: m,
key: m
}));
},
[itemsFromSomewhere]
);
const onValueChange = useCallback(
val => {
setValue(val);
},
[setValue]
);
return (
<View flex bg-red30>
<SafeAreaView style={{ flex: 1 }}>
<Picker
migrate
migrateTextField
value={value}
onChange={onValueChange}
useNativePicker
>
{items.map(option => (
<Picker.Item
key={option.key}
value={option.value}
label={option.label}
/>
))}
</Picker>
</SafeAreaView>
</View>
);
}
When useNativePicker is false, the warning does not occur.
Environment
- React Native: 0.64.3
- React Native UI Lib: 6.13.1
Affected platforms
- [ ] Android
- [X] iOS
- [ ] Web
I think I have a slightly different issue. I tried running your example and I'm getting this error:
undefined is not an object (evaluating 'Object.keys(componentPropTypes)')
React Native: 0.68.1 React Native UI Lib: 6.14.1 Platform: iOS
I am also getting this error.
Invalid prop children of type object supplied to PickerDialog, expected array.
Any updates on this?
+1 Here as well.
Using useNativePicker works okay but throws this warning:
Failed prop type: Invalid prop children of type object supplied to PickerDialog, expected array