farhoudshapouran/react-native-ui-datepicker

Clicking on a date doesn't select it, but the onChange event is triggered

Closed this issue · 2 comments

Basically, when I click on a date in the calendar, there's no visual indicator that a date was selected; looking at the console, i can confirm that the event is triggered. I'll attach a video showcasing the issue. Here's my code:

import { Text, View } from "react-native";
import DateTimePicker from "react-native-ui-datepicker";

const MyAccountTab = () => {
  return (
    <View>
      <Text>My Account</Text>

      <DateTimePicker mode="single" onChange={(e) => console.log(e)} />
    </View>
  );
};

export default MyAccountTab;
Screen.Recording.2024-11-06.at.17.46.32.mov

That's because date value is not defined. If add date variable and set it on onChange event it's going to work. Something like this:
<DateTimePicker mode="single" onChange={e => setSelectedDate(e.date)} date={selectedDate} />

Thank you, that was indeed the issue. Closing this now.