This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react'; | |
const useDebounce = (value, delay = 500) => { | |
// State and setters fpr debounced value | |
const [debouncedValue, setDebouncedValue] = useState(value); | |
useEffect(() => { | |
const handler = setTimeout(() => { | |
setDebouncedValue(value); | |
}, delay); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Max Date | |
const { format, isBefore, isValid, subYears, parseISO } = require('date-fns'); | |
const maxDate = format(subYears(new Date(), 18), 'yyyy-MM-dd'); | |
const maxResult = isBefore(dobDate, parseISO(maxDate, 1)); | |
// Min Date | |
// Requires Date FNS | |
const { format, isAfter, subYears, parseISO } = require('date-fns'); |