Array.map is not working in react build

What is wrong with my code?
I have used array.map method on an array of objects.
it works well in local environment but it dose not work in react build

app link - https://shoplist-app.netlify.app/

repo link - GitHub - rushikemble/shopList

When you have a problem, please do some detective work.

When I go to your app link, I see this in the console:

react-dom.production.min.js:216 TypeError: i.map is not a function
at y (HomePage.js:109)

When I go to HomePage.js:109, I see:

{filterData.map((elem) => {

What is filterData? It is an object. It gets initialized with shops. When I log that out it is an object. When I log out filterData, it is always an object.

The error is occuring because objects to not have a map property or method so you are trying to run undefined as a function. That is a big no-no. This is what the error “i.map is not a function” is trying to tell you.

You need to figure out what that data should be and what shape it should have.

I’m sorry to pick on you here, but it’s a little bit unfair to just say “here is a complicated application using various libraries with the code split across a load of files, it’s broken, what’s wrong with it” and expect people to debug the application for you.

Please be more specific when asking questions. It’s much easier to show this on something like CodeSandbox, but if you’re showing code that’s on GH at least say which file, what the error is, what you’re trying to do, what’s not happening that you expect to happen.

1 Like