问题
I am using NativeBase components. I have Form
with the following field:
<Item floatingLabel last>
<Label>Buy dateі</Label>
<DatePicker
defaultDate={buyTime}
locale={"en"}
modalTransparent={false}
animationType={"fade"}
androidMode={"default"}
placeHolderText="Change buy date"
textStyle={{ color: "green" }}
placeHolderTextStyle={{ color: "#d3d3d3" }}
onDateChange={this.handleBuyTimeChange}
disabled={false}
ref={component => (this.buyTimePicker = component)}
/>
<Input
value={buyTime.toString().substr(4, 12)}
onPress={() => {
this.buyTimePicker.showDatePicker();
}}
/>
</Item>
But clicking on Input
doesn't trigger DatePicker
. How this can be fixed?
回答1:
You cannot customize nativebase datepicker with your own input component and if you insist to you can use any 3rd party library for eg: https://www.npmjs.com/package/react-native-modal-datetime-picker.
来源:https://stackoverflow.com/questions/54047385/nativebase-how-to-show-datepicker-when-clicking-input