WeekProvider

An alternative approach for using a week calendar. This provider gives you the properties of a week as render props.

Again, the naming scheme is probably confusing, might be renamed to something else in the future.

Parameters

NameTypeDefaultDescription
initialDateDatenew Date()The date to use as the base for the calendar, the week is chosen based off this date.
childrenFunction-A function that returns a React element.
import { WeekProvider } from 'react-temporal-ui';

const Week = () => {
  return (
    <WeekProvider>
      {({ days, nextWeek, prevWeek }) => (
        <>
          <button onClick={prevWeek}>Prev</button>
          <button onClick={nextWeek}>Next</button>

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