I want to create a component, which consists of Datepicker and ChoiceGroup using ReactJs and office365. On first render datepicker must be disabled, and when we choose custom radio button in ChoiceGroup it must be enabled.Piece of code:
<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>
picker has disabled
param and I wanted to change it in ChoiceGrou method:
onChange = (ev, option) => {
console.dir(option);
if(option.key === 'custom') {
this.setState({
pickerDisabled: false
})
} else {
this.setState({
pickerDisabled: true
})
}
}
This method works and changes parameter, but datepicker component's disable doesnt change. it remains the same and I got error in console when I click any radio button:
Exception in DatePicker.componentWillReceiveProps(): TypeError: date1.getFullYear is not a function
What can be the reason of this error?