Question: I make a react.js app using the API "<https://www.definitions.net/definitions_api.php>".
When I log data.result, it outputs the right array of results, but when I map through the state, I get this error: "Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead." 

```
//states
  const [definition, setDefinition] = useState([])
  const [search, setSearch] = useState('')
  const [query, setQuery] = useState('')

  useEffect(() => {
    getDef()
   }, [query])

//FETCH
  const getDef = async () => {
  const response = await fetch(`....`)
  const data = await response.json()
  setDefinition(data.result);

//handle input
  const updateSearch = e => {
    setSearch(e.target.value)

  }

//get the final query onSubmit
const getQuery = e =>{
  e.preventDefault()
  setQuery(search)
  setSearch('')
}

 return (

  { definition && definition.map(item => (
       <Definition term={item.term} 
                  partofspeech = {item.partofspeech}
                  definition={item.definition} 
                  example = {item.example}                 
             />

            )
         )
        }

  );

```

in Definitions component I destructure the props:

```
function Definition({term, partofspeech, definition, example}) {
    return (
        <div className="definition">
            <h4>{term} ({partofspeech})</h4>
              <p>{definition}</p>
               <p>{example}</p>

        </div>
    )
}

```

Any help is welcome, thanks.

Answer: 
Try this, when you loop the component loop the definition without the root element, it will cause error

```js
const Component = () => {
  ....
  return (
    <Fragment>
      { definition && definition.map(item => (
       <Definition term={item.term} 
                  partofspeech = {item.partofspeech}
                  definition={item.definition} 
                  example = {item.example}                 
             />

            )
         )
        }

  )
    </Fragment>
  )
}
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
```
in return you have both `({})` round and curly, you can remove both and you should return directly

```
return definition && definition.map(item => (
       <Definition term={item.term} 
            partofspeech = {item.partofspeech}
            definition={item.definition} 
            example = {item.example}                 
        />
    ));

```

---

Short snippet, you can run it and review :

```js
const { useState } = React;

const App = () => {

  const [users,setUsers] = useState(['Vivek' , 'Darshita', 'Darshvi' , 'Coming..']);

  return users.map(user => <p>{user}</p>);
}

ReactDOM.render(<App />, document.getElementById('react-root'));
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.4/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.4/umd/react-dom.production.min.js"></script>
<div id="react-root"></div>
```