react-native-ui-lib icon indicating copy to clipboard operation
react-native-ui-lib copied to clipboard

Failed prop type: Invalid prop children of type object supplied to IGNORE

Open ldewald opened this issue 3 years ago • 2 comments

Description

When using the Picker component with prop useNativePicker, I encounter the warning:

Warning: Failed prop type: Invalid prop children of type object supplied to IGNORE, expected array.

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

ldewald avatar Apr 14 '22 10:04 ldewald

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

LazyAfternoons avatar May 13 '22 13:05 LazyAfternoons

I am also getting this error. Invalid prop children of type object supplied to PickerDialog, expected array.

brentrbutcher avatar Sep 05 '22 19:09 brentrbutcher

Any updates on this?

itajenglish avatar Oct 30 '22 23:10 itajenglish

+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

lakardion avatar Nov 01 '22 12:11 lakardion