fix: should use moment.isMoment, close: #4147

This commit is contained in:
Benjy Cui 2016-12-06 14:21:17 +08:00
parent 883066820a
commit 273faafaa2
3 changed files with 4 additions and 4 deletions

View File

@ -65,7 +65,7 @@ export default class Calendar extends React.Component<CalendarProps, any> {
constructor(props) {
super(props);
const value = props.value || props.defaultValue || moment();
if (!(value instanceof moment)) {
if (!moment.isMoment(value)) {
throw new Error(
'The value/defaultValue of Calendar must be a moment object after `antd@2.0`, ' +
'see: http://u.ant.design/calendar-value'

View File

@ -16,8 +16,8 @@ export default class RangePicker extends React.Component<any, any> {
super(props);
const value = props.value || props.defaultValue || [];
if (
value[0] && !(value[0] instanceof moment) ||
value[1] && !(value[1] instanceof moment)
value[0] && !moment.isMoment(value[0]) ||
value[1] && !moment.isMoment(value[1])
) {
throw new Error(
'The value/defaultValue of RangePicker must be a moment object array after `antd@2.0`, ' +

View File

@ -64,7 +64,7 @@ export default class TimePicker extends React.Component<TimePickerProps, any> {
constructor(props) {
super(props);
const value = props.value || props.defaultValue;
if (value && !(value instanceof moment)) {
if (value && !moment.isMoment(value)) {
throw new Error(
'The value/defaultValue of TimePicker must be a moment object after `antd@2.0`, ' +
'see: http://u.ant.design/time-picker-value'