From 273faafaa255f1ca7066ffe431dd736add83c22f Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Tue, 6 Dec 2016 14:21:17 +0800 Subject: [PATCH] fix: should use moment.isMoment, close: #4147 --- components/calendar/index.tsx | 2 +- components/date-picker/RangePicker.tsx | 4 ++-- components/time-picker/index.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/calendar/index.tsx b/components/calendar/index.tsx index d0d35e1178..46b76c49bd 100644 --- a/components/calendar/index.tsx +++ b/components/calendar/index.tsx @@ -65,7 +65,7 @@ export default class Calendar extends React.Component { 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' diff --git a/components/date-picker/RangePicker.tsx b/components/date-picker/RangePicker.tsx index ba6e3a54fc..eb91c4a925 100644 --- a/components/date-picker/RangePicker.tsx +++ b/components/date-picker/RangePicker.tsx @@ -16,8 +16,8 @@ export default class RangePicker extends React.Component { 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`, ' + diff --git a/components/time-picker/index.tsx b/components/time-picker/index.tsx index f8ad92e502..fd74ee6e1d 100644 --- a/components/time-picker/index.tsx +++ b/components/time-picker/index.tsx @@ -64,7 +64,7 @@ export default class TimePicker extends React.Component { 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'