Skip to content
Advertisement

Uncaught TypeError: Cannot read properties of undefined (reading ‘name’) | Material UI

I’m trying to view the fetched data on MUI Autocomplete, but I get this error I don’t why, the stat is fetched from MongoDB and I’m just trying to view the name of the category as an option.

enter image description here

The Code:

JavaScript

This is how the data is showing in Mongodb enter image description here

Advertisement

Answer

So I added this and it worked getOptionLabel={option => (option ? option.name : "")}

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement