user11092881
user11092881

Reputation:

Setting minDate to false or equivalent when using Material-UI DateTimePicker component

Type 'false | Moment' is not assignable to type 'Moment'.
  Type 'boolean' is not assignable to type 'Moment'.

<DateTimePicker
                    autoOk
                    ampm={false}
                    showToolbar={false}
                    minDate={props.disabledMin ? moment() : false} />

So I would like to disable minDate when props.disableMin is set to false, but minDate is expecting a Moment type, is there a way to disable it without having to copy paste DateTimePicker and then removing the minDate when props.disableMin is set to false? Because I am pretty sure that's bad practice.

Upvotes: 0

Views: 43

Answers (1)

Hamed Siaban
Hamed Siaban

Reputation: 1681

I think you are trying to prevent user from selecting past days if disabledMin in set to true. In that case you can try disablePast property instead:

<DateTimePicker
  autoOk
  ampm={false}
  showToolbar={false}
  disablePast={props.disabledMin} 
/>

Upvotes: 0

Related Questions