useWeek
A hook that returns a week calendar object, with navigation functions and a list of the days within a week.
Parameters
Name | Type | Default | Description |
---|---|---|---|
initialDate | Date | new Date() | The date to use as the base for the calendar, the week is chosen based off this date. |
useDayjs | bool | false | Whether 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>
))}
</>
);
};