Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Disable all days before and after given dates

I am trying to limit the user to be able to choose from a very small range of dates using react day picker. All other dates before and after should be disabled to prevent them from being selected. Below is my DateRange component with props which passes the values as strings such as 2022-07-15. The method I have attempted was taken from some previous questions on here, perhaps I am implementing it wrong?

const DateRange = (props) => {

return (
    <DayPicker
        mode="single"
        disabledDays={{ before: new Date(props.startdate), after: new Date(props.enddate) }}
    />
);

};

However no dates get visually disabled (greyed out) and the user can still select any date. Any help as to how to correct this would be much appreciated!

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

I made a sandbox, is this what you expect?

export default function App() {
  function _DayPicker({ before, after }) {
    const afterMatcher: DateAfter = { after };
    const beforeMatcher: DateBefore = { before };

    const disabledDays = [afterMatcher, beforeMatcher];

    return (
      <DayPicker
        defaultMonth={new Date(2022, 5, 10)}
        disabled={disabledDays}
        mode="single"
      />
    );
  }

  return (
    <_DayPicker before={new Date(2022, 5, 10)} after={new Date(2022, 5, 28)} />
  );
}
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!