Add upgrade warning (#4028)

* chore: add upgrade warning for time related value

* chore: update warning

* chore: update demo url
pull/4113/head
Benjy Cui 8 years ago committed by 偏右
parent a939769069
commit c4d8c4770c

@ -56,7 +56,8 @@ export default class Breadcrumb extends React.Component<BreadcrumbProps, any> {
const props = this.props;
warning(
!('linkRender' in props || 'nameRender' in props),
'`linkRender` and `nameRender` are removed, please use `itemRender` instead.'
'`linkRender` and `nameRender` are removed, please use `itemRender` instead, ' +
'see: http://u.ant.design/item-render.'
);
}

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

@ -14,8 +14,18 @@ export default class RangePicker extends React.Component<any, any> {
constructor(props) {
super(props);
const value = props.value || props.defaultValue || [];
if (
value[0] && !(value[0] instanceof moment) ||
value[1] && !(value[1] instanceof moment)
) {
throw new Error(
'The value/defaultValue of RangePicker must be a moment object array after `antd@2.0`, ' +
'see: http://u.ant.design/date-picker-value'
);
}
this.state = {
value: props.value || props.defaultValue || [],
value,
open: props.open,
};
}

@ -24,8 +24,15 @@ export default function createPicker(TheCalendar) {
getInitialState() {
const props = this.props;
const value = props.value || props.defaultValue;
if (value && !(value instanceof moment)) {
throw new Error(
'The value/defaultValue of DatePicker or MonthPicker must be ' +
'a moment object after `antd@2.0`, see: http://u.ant.design/date-picker-value'
);
}
return {
value: props.value || props.defaultValue,
value,
tempValue: undefined,
};
},

@ -22,6 +22,10 @@ function getColumns({ showHour, showMinute, showSecond }) {
export default function wrapPicker(Picker, defaultFormat?) {
const PickerWrapper = React.createClass({
contextTypes: {
antLocale: PropTypes.object,
},
getDefaultProps() {
return {
format: defaultFormat || 'YYYY-MM-DD',
@ -42,10 +46,6 @@ export default function wrapPicker(Picker, defaultFormat?) {
};
},
contextTypes: {
antLocale: PropTypes.object,
},
handleOpenChange(open) {
const { onOpenChange, toggleOpen } = this.props;
onOpenChange(open);
@ -54,7 +54,7 @@ export default function wrapPicker(Picker, defaultFormat?) {
warning(
false,
'`toggleOpen` is deprecated and will be removed in the future, ' +
'please use `onOpenChange` instead'
'please use `onOpenChange` instead, see: http://u.ant.design/date-picker-on-open-change'
);
toggleOpen({open});
}

@ -126,7 +126,8 @@ export default class Form extends React.Component<FormProps, any> {
deprecatedGetFieldProps(name, option) {
warning(
false,
'`getFieldProps` is not recommended, please use `getFieldDecorator` instead'
'`getFieldProps` is not recommended, please use `getFieldDecorator` instead, ' +
'see: http://u.ant.design/get-field-decorator'
);
return this.__getFieldProps(name, option);
},

@ -67,7 +67,8 @@ export default class Menu extends React.Component<MenuProps, any> {
warning(
!('onOpen' in props || 'onClose' in props),
'`onOpen` and `onClose` are removed, please use `onOpenChange` instead.'
'`onOpen` and `onClose` are removed, please use `onOpenChange` instead, ' +
'see: http://u.ant.design/menu-on-open-change.'
);
this.state = {

@ -2,6 +2,7 @@ import React from 'react';
import assign from 'object-assign';
import Tooltip from '../tooltip';
import { AbstractTooltipProps } from '../tooltip';
import warning from '../_util/warning';
export interface PopoverProps extends AbstractTooltipProps {
title?: React.ReactNode;
@ -29,7 +30,11 @@ export default class Popover extends React.Component<PopoverProps, any> {
getOverlay() {
const { title, prefixCls, content } = this.props;
warning(
!('overlay' in this.props),
'Popover[overlay] is removed, please use Popover[content] instead, ' +
'see: http://u.ant.design/popover-content'
);
return (
<div>
{title && <div className={`${prefixCls}-title`}>{title}</div>}

@ -131,8 +131,7 @@ export default class Table<T> extends React.Component<TableProps<T>, any> {
warning(
!('columnsPageRange' in props || 'columnsPageSize' in props),
'`columnsPageRange` and `columnsPageSize` are removed, please use ' +
'[fixed columns](http://ant.design/components/table/#components-table-demo-fixed-columns) ' +
'instead.'
'fixed columns instead, see: http://u.ant.design/fixed-columns.'
);
const pagination = props.pagination || {};

@ -63,9 +63,15 @@ export default class TimePicker extends React.Component<TimePickerProps, any> {
constructor(props) {
super(props);
const value = props.value || props.defaultValue;
if (value && !(value instanceof moment)) {
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'
);
}
this.state = {
value: props.value || props.defaultValue,
value,
};
}

Loading…
Cancel
Save