I have the following code on a React proyect using typescript:
interface ICountry {
id: string;
name: string;
}
...
const [countries, setCountries] = useState<ICountry[] | undefined>();
...
<Dropdown>
<DropdownTrigger>
<Button variant="bordered">Open Menu</Button>
</DropdownTrigger>
<DropdownMenu aria-label="Static Actions" items={countries}>
{(country) => (
<DropdownItem
key={country.id}
value={country.id}
onPress={(e: any) => setCountry(e.currentTarget.value)}
>
{country.name}
</DropdownItem>
)}
</DropdownMenu>
</Dropdown>
The problem is that country is a generic object and I get this error :
Property 'id' does not exist on type 'object'.
How can I type country to be able to use the properties of the objects and stop getting this error?