useToggleuseToggle+useEventRefuseSafeEffectuseEventControluseDebounceuseThrottleuseClickOutsideuseTabsuseDateuseDatesuseImageuseCaptureuseIntersectionObserver
react react-hook ironman30

useDates

A hook aims for manipulate two dates.


LINKS

鐵人賽文章

const [dates, datesDispatch] = useDate(configs)

//implented with [`date-fns`](https://date-fns.org/)

libs

date-fns


Default Config

Date: 2024-11-24 ~ 2024-11-24

const defaultConfigs = {
  defaultDate: null,
  formatPattern: "yyyy-MM-dd",
  transitionUnit: "days",
  offsetUnit: "days",
  offsetValue: 0,
  durationUnit: "days",
  durationDateOnIssue: 0, // 0 | 1 | 2
  minDuration: 0,
  maxDuration: 0,
  noPastDate: false,
  noFutureDate: false,
  noGreaterThenSecondDate: false,
}

Custom Config

Date: 2024-11-24 ~ 2024-11-24

const customConfigs = {
  defaultDate: null,
  formatPattern: "yyyy-MM-dd",
  transitionUnit: "days",
  offsetUnit: "days",
  offsetValue: 0,
  durationUnit: "days",
  durationDateOnIssue: 2, // 0 | 1 | 2
  minDuration: 5,
  maxDuration: 0,
  noPastDate: false,
  noFutureDate: false,
  noGreaterThenSecondDate: false,
}