refactor: cache the result of getLocale()

This commit is contained in:
Benjy Cui 2015-11-21 16:48:35 +08:00
parent dc9dd43e39
commit bbadcc34c1

View File

@ -87,18 +87,19 @@ function createPicker(TheCalendar) {
this.props.onChange(timeValue); this.props.onChange(timeValue);
}, },
render() { render() {
const locale = this.getLocale();
// //
// //
// //
let defaultCalendarValue = new GregorianCalendar(this.getLocale()); let defaultCalendarValue = new GregorianCalendar(locale);
defaultCalendarValue.setTime(Date.now()); defaultCalendarValue.setTime(Date.now());
const placeholder = ('placeholder' in this.props) const placeholder = ('placeholder' in this.props)
? this.props.placeholder : this.getLocale().lang.placeholder; ? this.props.placeholder : locale.lang.placeholder;
const calendar = ( const calendar = (
<TheCalendar <TheCalendar
disabledDate={this.props.disabledDate} disabledDate={this.props.disabledDate}
locale={this.getLocale().lang} locale={locale.lang}
defaultValue={defaultCalendarValue} defaultValue={defaultCalendarValue}
dateInputPlaceholder={placeholder} dateInputPlaceholder={placeholder}
showTime={this.props.showTime} showTime={this.props.showTime}