Skip to content

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

@ldewald

Description

@ldewald

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

  • Components
  • Demo
  • Docs
  • Typings

Steps to reproduce

Modifying/simplifying the example from #1749 (comment) 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
  • iOS
  • Web

Metadata

Metadata

Assignees

No one assigned

    Labels

    buga bug in one of the components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions