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

140
Visualizações
How do I animate react-bootstrap progress bar from 0 to N on page load?

I am using the react-bootstrap ui library for the progress bar. I want it to animate the progress bar from 0 to 70 on page load.

How do I achieve it?

Here is the code

Component.js

<ProgressBar
        animated
        now={70}
        className="progress-bar"
      />

Component.style

.progress-bar {
  width: 400px;
}

Expected OutPut: It should animate from 0 to 70 on page load. enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The animate property doesn't animate the progress, but animates the stripes on the progress bar.

From the docs:

Animate's the stripes from right to left

What you need is a timer that updates the now property. Probably something like this:

const MyComp = () => {
 const [progressNow, setProgressNow] = useState(0)

 const updateProgressNowHandler = setInterval(() => {
  if (progressNow >= 70 ){
   setProgressNow(70)
   clearInterval(updateProgressNowHandler)
  }
  setProgressNow(s => s+1)
 }, 50)

 return 
  <ProgressBar
        animated
        now={progressNow}
        className="progress-bar"
      />
}

This is by no means production ready.

You need to make sure that you clear the interval when the component unmounts.

If there is a chance that the component will be re-rendered (which most likely will happen) you need to keep track of the progress already made and start with the counter from the last value.

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