Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
how to disable some dates in react-calendar

Could someone tell me how to pass an array of disabled dates to the calendar?

I searched but couldn't find how to do it

https://www.npmjs.com/package/react-calendar

import React, { useState, useEffect} from 'react';
import Api from '../../services/api';
import Calendar from 'react-calendar';
import { useParams } from "react-router-dom";
import 'react-calendar/dist/Calendar.css';

function MyApp() {
  const { id } = useParams();
  const [value, onChange] = useState(new Date());
  const [disabledDates, setDisabledDates] = useState([]);

  useEffect(() => {
    loadDisabledDates();
  }, []);

  function loadDisabledDates()
  {
    Api
      .get("/dates/"+id)
      .then((response) => {
        setDisabledDates(response.data);
      })
      .catch((err) => {
        console.error("error: " + err);
      });
  }

  return (
    <div>
      <Calendar onChange={onChange} value={value} />
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Edit: Scrolling further down the documentation, there is also a prop called tileDisabled. So that's probably your answer.

First answer: It looks, from the documentation, like your best bet is use the available props onClickDay, onClickMonth, etc

const handleClickDay = (e) => {
    if(disableDates.includes(e.target.value)){
        alert('this date is disabled')
    }else{
        //do something with the date
    }
}
return(
    <Calendar onChange={onChange} value={value}
        onClickDay={handleClickDay} />
)

I haven't used this library, so I'm not sure e.target.value will give you exactly the data but it should be something like this.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda