0
我想創建一個組件,它由使用ReactJs和office365的Datepicker和ChoiceGroup組成。在第一次渲染日期選擇器必須禁用,當我們在ChoiceGroup的選擇定製單選按鈕,它必須是代碼enabled.Piece:DatePicker禁用錯誤
<div>
<ChoiceGroup
defaultSelectedKey='all'
onChange={ this._onChange }
label='Date'
options={ [
{
key: 'all',
text: 'All'
},
{
key: 'thisWeek',
text: 'This week',
},
{
key: 'lastWeek',
text: 'Last week',
},
{
key: 'thisMonth',
text: 'This month',
},
{
key: 'custom',
text: 'Custom',
}
] }
/>
<DatePicker
label='label'
isRequired={ false }
disabled={ pickerDisabled }
strings={ strings }
allowTextInput={ false }
value={ value }
/>
</div>
選擇器具有disabled
PARAM,我想改變它在ChoiceGrou方法:
onChange = (ev, option) => {
console.dir(option);
if(option.key === 'custom') {
this.setState({
pickerDisabled: false
})
} else {
this.setState({
pickerDisabled: true
})
}
}
此方法工作並更改參數,但datepicker組件的禁用不會更改。它仍然是相同的,當我點擊任何單選按鈕,我得到了在控制檯錯誤:
Exception in DatePicker.componentWillReceiveProps(): TypeError: date1.getFullYear is not a function
什麼可以這個錯誤的原因是什麼?
你是對的我把新的日期()值和它的工作原理,謝謝 –