Reputation: 466
I want to add for each button of day - ID. Its needed for automation tests and other things.
const CustomDay = (props: any) => {
const { day } = props;
const uniqueId = `day-${format(day, 'yyyy-MM-dd')}`; // unique ID for each day
return (
<div id={uniqueId} key={uniqueId}>
<PickersDay {...props} day={day} />
</div>
);
};
And then added as a slot to DatePicker slots={{ day: CustomDay }}
But after this i need to click twice and super fast in order to select a date. What i am doing wrong and how i can add IDs to PickersDay component?
Upvotes: 1
Views: 214
Reputation: 466
The error was very simple my Custom component was declared inside of the component, so after I moved the code to a separate file/component it works.
Upvotes: 1