NativeBase
NativeBase copied to clipboard
DatePicker: show default date instead of "Select Date" if placeHolderText prop isn't specified
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
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}
...
/>