useWeek

A hook that returns a week calendar object, with navigation functions and a list of the days within a week.

Parameters

NameTypeDefaultDescription
initialDateDatenew Date()The date to use as the base for the calendar, the week is chosen based off this date.
useDayjsboolfalseWhether to return day.js objects or not

Usage

import { useWeek } from 'react-temporal-ui';

const Week = () => {
  const { days, nextWeek, prevWeek } = useWeek();

  return (
    <>
      <button onClick={prevWeek}>Prev</button>
      <button onClick={nextWeek}>Next</button>

      {days.map((day, i) => (
        <p key={i}>{day.getDate()}</p>
      ))}
    </>
  );
};