Skip to content

Commit 8cde6e2

Browse files
committed
typing Day with React.memo
1 parent 03c1026 commit 8cde6e2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/calendar/day/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export interface DayProps extends BasicDayProps {
1616
dayComponent?: React.ComponentType<DayProps & {date?: DateData}>;
1717
}
1818

19-
const Day = (props: DayProps) => {
19+
const Day = React.memo((props: DayProps) => {
2020
const {date, marking, dayComponent, markingType} = props;
2121
const _date = date ? new XDate(date) : undefined;
22-
const _isToday = _date ? isToday(_date) : undefined;
22+
const _isToday = isToday(_date);
2323

2424
const markingAccessibilityLabel = useMemo(() => {
2525
let label = '';
@@ -59,6 +59,7 @@ const Day = (props: DayProps) => {
5959

6060
const Component = dayComponent || markingType === 'period' ? PeriodDay : BasicDay;
6161

62+
console.warn(date);
6263
return (
6364
<Component
6465
{...props}
@@ -68,9 +69,10 @@ const Day = (props: DayProps) => {
6869
{formatNumbers(_date?.getDate())}
6970
</Component>
7071
);
71-
};
72+
}) as any;
73+
74+
export default Day;
7275

73-
export default React.memo<DayProps>(props => <Day {...props}/>);
7476
Day.displayName = 'Day';
7577
Day.propTypes = {
7678
...BasicDay.propTypes,

0 commit comments

Comments
 (0)