Revert "docs: Fix LocelProvider demo"

This reverts commit 6f9c8da502.
This commit is contained in:
Wei Zhu 2018-01-15 14:39:25 +08:00
parent d9062bdb5c
commit 96c312f8fb

View File

@ -17,9 +17,9 @@ Components which need localization support are listed here, you can toggle the l
import { LocaleProvider, Pagination, DatePicker, TimePicker, Calendar,
Popconfirm, Table, Modal, Button, Select, Transfer, Radio } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
import enUS from 'antd/lib/locale-provider/en_US';
import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('en');
const Option = Select.Option;
const RangePicker = DatePicker.RangePicker;
@ -108,20 +108,25 @@ class App extends React.Component {
constructor() {
super();
this.state = {
locale: enUS,
locale: null,
};
}
changeLocale = (e) => {
const localeValue = e.target.value;
this.setState({ locale: localeValue });
if (!localeValue) {
moment.locale('en');
} else {
moment.locale('zh-cn');
}
}
render() {
return (
<div>
<div className="change-locale">
<span style={{ marginRight: 16 }}>Change locale of components: </span>
<Radio.Group defaultValue={enUS} onChange={this.changeLocale}>
<Radio.Button key="en" value={enUS}>English</Radio.Button>
<Radio.Group defaultValue={null} onChange={this.changeLocale}>
<Radio.Button key="en" value={null}>English</Radio.Button>
<Radio.Button key="cn" value={zhCN}>中文</Radio.Button>
</Radio.Group>
</div>