I have been facing an issue while trying to pass a prop from a custom object I have defined. The structure of the object is as follows:
export type CustomObjectType = {
data?: DataObject
};
export type DataObject = {
id: number;
name: string;
description: string;
status: Boolean;
date_created: Date | string;
date_updated: Date | string;
priority: number;
category: string;
comments?: string;
department: string;
tags: string[];
attachments: string[];
report_files: string[];
project_status: string;
user_id: number;
contact_person: string;
authorized_persons: string[];
}
Below is the section in my component where I am attempting to pass it:
import { DataObject, CustomObjectType } from '../customObjects/CustomObjectType';
import { styles } from '../design';
type DataProps = {
data: DataObject;
};
const DisplayData: React.FC<DataProps> = ({ data }) => {
console.log("Hello", data);
return (
<div justify-content-between>
<p>Name: {data.name}</p>
{/* Include additional components that utilize `data` */}
</div>
);
};
export default DisplayData;
The issue arises as I consistently receive an error stating "cannot read properties of undefined" whenever I try to access a field within the custom object.