In order to use Typescript feature under react-admin, I followed this official example to type the Edit title:
interface UserTitleProps {
record: UserRecord;
}
const UserTitle: FC<UserTitleProps> = ({ record }) => {
const identifier = record?.email || record?.phoneNumber;
if (record?.name) {
return `${record?.name} (${identifier})`;
}
return identifier;
};
export const UserEdit: FC<EditProps> = (props) => (
<Edit
title={<UserTitle />}
{...props}
>
<UserForm />
</Edit>
);
But the code above gave me the following typescript error:
Property 'record' is missing in type '{}' but required in type 'UserTitleProps'. TS2741
103 | export const UserEdit: FC<EditProps> = (props) => (
104 | <Edit
> 105 | title={<UserTitle />}
| ^
106 | {...props}
107 | >
108 | <UserForm />
Indeed, the record props is not really passed but according to the documentation and the following sample, there is nothing to add.
Am I missing something?
Thanks