Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit ccebba8

Browse files
committed
Use getMonthNames instead of repetitive code
1 parent 03b57e7 commit ccebba8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/Calendar/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Calendar extends PureComponent {
3838
this.listSizeCache = {};
3939
this.isFirstRender = true;
4040
this.state = {
41-
monthNames: [...Array(12).keys()].map(i => props.locale.localize.month(i)),
41+
monthNames: this.getMonthNames(),
4242
focusedDate: calcFocusDate(null, props),
4343
drag: {
4444
status: false,
@@ -48,6 +48,10 @@ class Calendar extends PureComponent {
4848
scrollArea: this.calcScrollArea(props),
4949
};
5050
}
51+
getMonthNames() {
52+
return [...Array(12).keys()].map(i => this.props.locale.localize.month(i));
53+
}
54+
5155
calcScrollArea(props) {
5256
const { direction, months, scroll } = props;
5357
if (!scroll.enabled) return { enabled: false };
@@ -129,7 +133,7 @@ class Calendar extends PureComponent {
129133
if (this.props.weekStartsOn !== undefined)
130134
this.dateOptions.weekStartsOn = this.props.weekStartsOn;
131135
this.setState({
132-
monthNames: [...Array(12).keys()].map(i => this.props.locale.localize.month(i)),
136+
monthNames: this.getMonthNames(),
133137
});
134138
}
135139

0 commit comments

Comments
 (0)