Skip to content

onMonthChange doesnt workΒ #195

@nmpereira

Description

@nmpereira

Using the minimally reproduced example, the log for "date" runs on onChange (when clicking on a date), however, the "month" log doesnt run on onMonthChange (when clicking on the month previous/next buttons)

import { View } from "react-native";
import { useState } from "react";
import DateTimePicker, {
  DateType,
  useDefaultStyles,
} from "react-native-ui-datepicker";

export default function HomeScreen() {
  const defaultStyles = useDefaultStyles();
  const [selected, setSelected] = useState<DateType>();
  const [month, setMonth] = useState<number>(new Date().getMonth());

  const onChange = ({ date }: { date: DateType }) => {
    setSelected(date);
    console.log("date", date);
  };

  const onMonthChange = (month: number) => {
    setMonth(month);
    console.log("month", month);
  };
  return (
    <View style={{ flex: 1 }}>
      <DateTimePicker
        mode="single"
        date={selected}
        onChange={onChange}
        styles={defaultStyles}
        month={month}
        onMonthChange={onMonthChange}
      />
    </View>
  );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions