RNDateTimePicker requires to pass date value. Is it possible to NOT pass a value but a placeholder instead?

Viewed 44

My RNDateTimePicker component looks like this:

<RNDateTimePicker
  value={new Date()} // Current date
  mode='date'
  display='default'
  ...
/>

That generates an input field with the current date, and that's fine. But I'm looking to NOT to provide a value but a placeholder UNLESS the user clicks on the Date Input Field and selects a date.

So the input date field would look more or less like this: [MM-DD-YYYY] instead of [9/13/21].

If I were to pass a null value to the value prop of the component it would error out telling me that I must provide a date value.

Is this possible?

1 Answers

You could create a prop placeholder separeted from the value. The date needs to be valid for a usability purposes indead.

Inside the component you can make something like <input value={isDate ? props.value : '0000-00-00' } placeholder={isDate ? 'any' : 'thing'}>

Related