React doesn't recognize an array

Hello. I’m trying to pass an array of objects to my array component but I get the error saying that I’m trying to pass an object. Here’s the code:

let array = [
  { item: "Hello", key: 1 },
  { item: "Hello2", key: 2 },
const primary = (args) => {
  return <Select>{array}</Select>;

And I get this:

Objects are not valid as a React child (found: object with keys {item, key}). If you meant to render a collection of children, use an array instead.

Hi you are passing array so you need to iterate over the array using map.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.