bradtraversy / mern_shopping_list

Shopping List built with MERN and Redux
605 stars 436 forks source link

TypeError: "t.map is not a function" value ShoppingList.js:30 #12

Open RickJP opened 5 years ago

RickJP commented 5 years ago

I don't get this error when testing locally. Everything functions perfectly. It is only after I've deployed to Heroku. I've checked the Heroku logs and there's no problem there.

I can see the app run for a fraction of a second and then get a blank screen; whether I use Chrome, Firefox, or Safari.

I hope someone can help.

shashankshetty1996 commented 5 years ago

Can you drop in your repository link here? So that we can look into your code once. Also, check if you have connected to the item store. It is because your extracting items from item reducer.

RickJP commented 5 years ago

Sure. Here it is git@github.com:RickJP/TRAVERSY_MERN_Shopping_List.git

PJijin commented 5 years ago

The data from axios take some sec to load. Before actual data has arrived the map tries to works and the error is generated.

Try something like this on ShoppingList.js render

if (this.props.item === undefined) { return <div>Loading....</div>; } else { return <Container>........

ezapanta commented 5 years ago

If you're still having trouble with this, make sure you're using the route by placing app.use('/api/items', items) before serving the static assets

kentetics commented 4 years ago

same problem, did tried what @ezapanta suggested still have the same problem

edit: found the cause, I don't know why but it doesn't support the proxy json syntax at package.json. What I did is instead of axios.get('/api/items') on itemactions.js , i replaced it to axios.get('http://localhost:5000/api/items'). Hope it helps

aniquehussain commented 3 years ago

Thanks, @ezapanta, you are the man.

Shelroy commented 2 years ago

Thank you guys @kentetics. I was having the same problem and it solved it.

evandev01 commented 2 years ago

Moving app.use(routes) above static assets in server.js worked for me.

Thanks a ton @ezapanta.

khiet-alt commented 2 years ago

Thanks @kentetics , it's worked, it worked for me