Open Alver23 opened 6 years ago
automatically what?
the calendar should receive a prop so that it opens automatically without having to press on the icon or the text box and be able to position the icon on the left or right side
it opens automatically without having to press on the icon or the text box
I think there is a workaround, by using the ref
api of a React Component:
<DatePicker
date={this.state.birthday}
mode="date"
placeholder=" "
format="YYYY-MM-DD"
onDateChange={birthday => {
this.changeBirthday(birthday);
}}
ref={datePicker => this.datePicker = datePicker}
/>
and when I call it's onPressDate
function in the componentDidMount
hook method, it "automatically" show up without pressing anything:
componentDidMount() {
if (this.datePicker) {
this.datePicker.onPressDate();
}
}
and be able to position the icon on the left or right side
What I try to do here is to shut the icon down, an render a icon myself:
<View style={styles.row}>
<Icon /> /* just style this icon wherever you want */
<DatePicker
date={this.state.birthday}
mode="date"
placeholder=" "
onDateChange={birthday => {
this.changeBirthday(birthday);
}}
showIcon={false}
/>
</View>
thank you very much, I will try the solution provided
Issue
it is possible that the calendar can be automatically after calling the component
Expected Behavior
Code
Environment
react-native -v
: 0.49.5node -v
: 8.9.1npm -v
: 5.6.0yarn --version
: 1.3.2target platform
: Android | iOSoperating system
: Window 10 64 bits