1.0.2 • Published 10 months ago

use-calendar-react-hook v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

useCalendar React Hook

useCalendar is a React Hook written in TypeScript that generates calendar data. This hook is a utility that helps you to create flexible and customizable calendar-based components.

Installation

npm install use-calendar-react-hook
# or with yarn
yarn add use-calendar-react-hook

Usage

Import useCalendar from the package and use it in your component:

import useCalendar from "use-calendar-react-hook";

function App() {
  const {
    today,
    currentScope,
    selectedDate,
    currentMonth,
    selectDate,
    navigateMonth,
  } = useCalendar();

  // Use these variables and functions to build your calendar UI
  return <div>...</div>;
}

API

useCalendar()

The useCalendar hook generates and returns the following data and functions:

  • today: The current date
  • currentScope: An array of objects representing the dates to be displayed in the calendar. Each object has a date string, and optional isCurrentMonth, isToday, and isSelected booleans.
  • selectedDate: The currently selected date
  • currentMonth: The current month that the calendar is displaying
  • selectDate(date: Date): A function that sets the selected date
  • navigateMonth(offset: number): A function that changes the current month by the provided offset (positive for future months, negative for past months)

License

MIT

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago