xgfe / react-native-datepicker

react native datePicker component for both Android and IOS, useing DatePikcerAndroid, TimePickerAndroid and DatePickerIOS
MIT License
2.12k stars 725 forks source link

Canael Manually is not available #398

Open somushanker44 opened 4 years ago

somushanker44 commented 4 years ago

Issue

I want to close the modal after 10 seconds for which I tried using onPressCacel which is not working.

Expected Behavior

when you click on the date picker we should be able to dismiss the modal even with out confirm or cancel only then we can say it as a controlled component but this date picker uncontrolled.

Code

export default class App extends Component { state = { date: "2018-08-30" }

componentDidMount() {
  this.datePicker.onPressDate()
  setTimeout(() => {
    this.datePicker.onPressCancel()
  }, 5000)
}

render() {
  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <DatePicker
        style={{ width: 200 }}
        date={this.state.date}
        mode="date"
        duration={0}
        placeholder="select date"
        format="YYYY-MM-DD"
        confirmBtnText="Confirm"
        ref={ref => this.datePicker = ref}
        cancelBtnText="Cancel"
        onDateChange={(date) => { this.setState({ date: date }) }}
      />
    </View>
  );
}

}

Environment

  1. react-native -v:
  2. node -v:
  3. npm -v:
  4. yarn --version:
  5. target platform: Android | iOS
  6. operating system:
asmudevicsar commented 2 years ago

lo solucionaste?