I am trying to set max date in date picker getting error this
I am using this date picker https://www.npmjs.com/package/semantic-ui-calendar-react
render() {
return (
<DateInput
name="date"
placeholder="Date"
// this works
// maxDate={moment()}
// this is not working
maxDate={moment().subtract(1,'years')}
value={this.state.date}
iconPosition="left"
onChange={this.handleChange}
/>
);
}
here is my code
https://codesandbox.io/s/semantic-ui-example-v9v03
I am trying to set max date 1 year before
You need to set an initialDate
inside [minDate, maxDate] interval.
<DateInput
maxDate={moment().subtract(1, "years")}
initialDate={moment().subtract(1, "years")} <==
value={this.state.date}
/>
Source (not sure why this isn't mentioned on their documentation).