ant-design/components/locale-provider/index.tsx
Manjit Kumar 4e055ed5d0 use PropTypes from 'prop-types' mdoule instead of React
- as React.PropTypes is being deprecated
 - Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.
 - Solution: https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.proptypes
2017-04-12 02:22:05 +05:30

55 lines
1.0 KiB
TypeScript

import React from 'react';
import PropTypes from 'prop-types';
import { changeConfirmLocale } from '../modal/locale';
export interface LocaleProviderProps {
locale: {
Pagination?: Object,
DatePicker?: Object,
TimePicker?: Object,
Calendar?: Object,
Table?: Object,
Modal?: Object,
Popconfirm?: Object,
Transfer?: Object,
Select?: Object,
};
children?: React.ReactElement<any>;
}
export default class LocaleProvider extends React.Component<LocaleProviderProps, any> {
static propTypes = {
locale: PropTypes.object,
};
static childContextTypes = {
antLocale: PropTypes.object,
};
getChildContext() {
return {
antLocale: {
...this.props.locale,
exist: true,
},
};
}
componentWillMount() {
this.componentDidUpdate();
}
componentDidUpdate() {
const { locale } = this.props;
changeConfirmLocale(locale && locale.Modal);
}
componentWillUnMount() {
changeConfirmLocale();
}
render() {
return React.Children.only(this.props.children);
}
}