forked from gpbl/react-day-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeekday.js
More file actions
47 lines (42 loc) · 1.06 KB
/
Copy pathWeekday.js
File metadata and controls
47 lines (42 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React, { Component } from 'react';
import PropTypes from 'prop-types';
export default class Weekday extends Component {
static propTypes = {
weekday: PropTypes.number,
className: PropTypes.string,
locale: PropTypes.string,
localeUtils: PropTypes.object,
weekdaysLong: PropTypes.arrayOf(PropTypes.string),
weekdaysShort: PropTypes.arrayOf(PropTypes.string),
};
shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}
render() {
const {
weekday,
className,
weekdaysLong,
weekdaysShort,
localeUtils,
locale,
} = this.props;
let title;
if (weekdaysLong) {
title = weekdaysLong[weekday];
} else {
title = localeUtils.formatWeekdayLong(weekday, locale);
}
let content;
if (weekdaysShort) {
content = weekdaysShort[weekday];
} else {
content = localeUtils.formatWeekdayShort(weekday, locale);
}
return (
<div className={className} role="columnheader">
<abbr title={title}>{content}</abbr>
</div>
);
}
}