Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

TypeError: undefined is not an object (evaluating 'reminder.map')

this is my reminder-list.tsx, how many time i tricked it, i always fail to do that, how to fix it

i always got the TypeError: undefined is not an object (evaluating ‘reminder.map’) error

import { ReminderDetails } from "@/types/types";
import React from "react";

interface ReminderListProps {
  reminder: ReminderDetails[];
}

const ComponentReminderList: React.FC<ReminderListProps> = ({ reminder }) => {
  return (
    <tbody>
      {reminder.map((item, index) => (
        <tr key={index}>
          <td className="text-[hsl(210,17%,98%)] w-[20%] font-light text-xs px-4 py-4">
            {item.patient}
          </td>
          <td className="text-[hsl(210,17%,98%)] w-[20%] font-light text-xs px-4 py-4">
            {item.medicine}
          </td>
          <td className="text-[hsl(210,17%,98%)] w-[20%] font-light text-xs px-4 py-4">
            {item.dosage} - {item.dosage_unit}
          </td>
          <td className="text-[hsl(210,17%,98%)] w-[20%] font-light text-xs px-4 py-4">
            {item.schedule}
          </td>
          <td className="text-[hsl(210,17%,98%)] w-[20%] font-light text-xs px-4 py-4">
            {item.notes}
          </td>
        </tr>
      ))}
    </tbody>
  );
};

export default ComponentReminderList;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The error says in other words that you can’t read properties of undefined.

the reminder prop is somehow undefined and passed as undefined in the parent component. you should check where you used your ComponentReminderList component and check the props you passed.

Edit: I removed the early check of props because they will never be undefined since they are not optional in props interface

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading