Nativebase - how to show datepicker when clicking input?

女生的网名这么多〃 提交于 2019-12-11 04:27:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!