mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
4e055ed5d0
- 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
55 lines
1.0 KiB
TypeScript
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);
|
|
}
|
|
}
|