apaajabolehd / react-native-range-datepicker

react native range datepicker inspired by Airbnb
83 stars 53 forks source link

How to Open date picker onPress event #5

Closed 11et401012 closed 7 years ago

11et401012 commented 7 years ago

Hi I am trying react-native-range-datepicker My problem is how to open datepicker only onPress event .

apaajabolehd commented 7 years ago

You can use state flag to show the datepicker. For example

openDatepicker(){
  this.setState({
    openDatepicker : true
  });
}

render() {
  return (
    <ModalBox backdropPressToClose={false} swipeToClose={false} isOpen=
    {this.state.openDatepicker}>
      <DatepickerRange
        startDate: '13052017',
        untilDate: '26062017',
        onConfirm: {( startDate, untilDate ) => this.setState({ startDate, untilDate })} />
    </ModalBox>
  )
}

I'm using "react-native-modalbox" for the modal. You can use any other modal or just show it without modal, just use the flag like "openDatepicker" to open it. thank you