ReactJsとoffice365を使用してDatepickerとChoiceGroupのコンポーネントを作成したいとします。最初に日付ピッカーを無効にする必要があり、レンダリング、そして私たちはChoiceGroupの中でカスタムラジオボタンを選択したときには、コードのenabled.Pieceでなければなりません:DatePickerエラーを無効にする
ピッカーはdisabled
のparamを持っていると私はChoiceGrou方法でそれを変更したい
<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>
:
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
このエラーの原因は何ですか?
私は新しいDate()を値に付けて動作させていただきありがとうございます –