Nativebase: DatePicker: show default date instead of "Select Date" if placeHolderText prop isn't specified

Created on 3 Jul 2018  路  3Comments  路  Source: GeekyAnts/NativeBase

node, npm, react-native, react and native-base version

node: v9.8.0
react: 16.3.2
native-base: 2.6.1

Expected behaviour

Showing default date if placeHolderText prop isn't specified

Actual behaviour

Picker shows "Select Date" string

Is the bug present in both iOS and Android or in any one of them?

checked only in Android, can't test in ios

Most helpful comment

If anybody is still facing problem, then one use this hack:
Assign default date to placeholder text

placeHolderText={this.formatDate(your_default_date)}

export const formatDate = date => {
  return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
};

All 3 comments

Added with 2.7.1

If anybody is still facing problem, then one use this hack:
Assign default date to placeholder text

placeHolderText={this.formatDate(your_default_date)}

export const formatDate = date => {
  return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
};

Do this, I'm using native base 2.12.1.
<DatePicker defaultDate={value} placeHolderText={!value ? placeholder : null} ... />

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muthuraman007 picture muthuraman007  路  3Comments

Landerson352 picture Landerson352  路  3Comments

agersoncgps picture agersoncgps  路  3Comments

natashache picture natashache  路  3Comments

bsiddiqui picture bsiddiqui  路  3Comments