Max Tommy Mitschke Max Tommy Mitschke - 1 year ago 38
Javascript Question

.map() undefined even though I pass an array

I'm trying to map an array in my Component render method but it keeps saying .map is not a function even though it's an array.

return (
<select className="c-select">
<option value="">Choose your city</option>
{ => <option key={city.slug} value={city.slug}>{}</option>)}

The console log gives me this result:

I have no clue why .map is undefined - Am I missing something here?



If you're using Chrome or Firefox, it looks like state.cities.items is a JSON string, not an Array.



When you console.log real Arrays, the output will look like Array [ Object, Object ] in Firefox or >[Object] in Chrome