× TypeError: Cannot read properties of undefined (reading ‘map’)

I had the same error and solved it by first asking if the array existed.

Example:

<Filter>
  { product.color?.map((c) => (
    <FilterColor color = {c} key = {c} />
  ))};
</Filter>

Leave a Comment