I have a unique Med
interface containing properties like drugClass, dosage, and name. Using this interface, I created an array of drugs with different attributes. How can I filter this array by drugClass and then display the filtered data on a web page?
// in Medications.ts
export interface Med {
dosage: number;
name: string;
drugClass: medForm;
forDog: boolean;
forCat: boolean;
}
export const medications: Med[] = [
{
dosage: 0.03,
name: "Meloxicam",
drugClass: "Oral",
forDog: true,
forCat: true,
}, ....// more here
// in page.tsx
import { Med, medications } from "./Medications";
export default function Home() {
const filteredOralData = medications.filter(
(med) => med.drugClass === "Oral"
);
return (
<div>
<ul className="list-group">
{filteredOralData.map((item) => (
<li>{item //ERROR: Type 'Med' is not assignable to type 'ReactNode'.ts(2322)
index.d.ts(1450, 9): The expected type comes from property 'children' which is declared here on type 'DetailedHTMLProps<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>'}</li>
))}
</ul>
</div>