Cannot read property 'map' of undefined with react hooks

You need to check items isn't null/undefined before rendering:

{items && items.map(item => (
        <p>{item.name}</p>
      ))}

Working: https://codesandbox.io/s/24vkqzn6xy


Problem is in this line:

const [shop, setShop] = useState('')

Since you are expecting shop.items as an array, so define the initial state as:

const [shop, setShop] = useState({ items: [] });

Also assign unique key to each p, here:

<p key={item.itemid}>{item.name}</p>

Working Code.


You can also do it like this

{ items?.map(item => (<p>{ item.name }</p>)) }