You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
531 B
JavaScript

import React from 'react'
import styles from './Inventory.module.css'
import useGameState from '../../hooks/useGameState'
export default function () {
const state = useGameState()
const allItems = Array.from(state.items.values())
const inventory = allItems.filter(({location}) => location === 'inventory')
return (
<>
<h3>You have:</h3>
<ul className={styles.list}>
{inventory.map(item => (<li>{item.name}</li>))}
{inventory.length === 0 && (<li>Nothing</li>)}
</ul>
</>
)
}