Skip to content

Commit 45687c9

Browse files
committed
[fixed] allow string names in move()
1 parent a25776b commit 45687c9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/utils/dates.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint no-fallthrough: 0 */
1+
/* eslint no-fallthrough: off */
22
import dateMath from 'date-arithmetic';
33
import localizer from '../localizer';
44

src/utils/move.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
import invariant from 'invariant';
12
import { navigate } from './constants';
3+
import VIEWS from '../Views';
24

35
export default function moveDate(action, date, View){
4-
switch (action){
6+
View = typeof view === 'string' ? VIEWS[View] : View;
7+
8+
switch (action) {
59
case navigate.TODAY:
610
date = new Date()
711
break;
812
case navigate.DATE:
913
break;
1014
default:
15+
invariant(View && typeof View.navigate === 'function',
16+
'Calendar View components must implement a static `.navigate(date, action)` method.s')
1117
date = View.navigate(date, action)
1218
}
13-
1419
return date
1520
}

0 commit comments

Comments
 (0)