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

123
Visualizações
Bootstrap 5, same code not working in my local but works in codeply

I am trying to reproduce this scrollspy example from bootstrap website.

Here is how I reproduce it: https://yue-site-front.herokuapp.com/ You can inspect the code.

The navigation links work good, but according to bootstrap's doc:

As you scroll the “spied” container, an .active class is added and removed from anchor links within the associated navigation.

This is something i didnt observe. I inspected the code and active class is not appeared as i view different titles on the screen.

I believe I am using data attribute method to let is work, as the doc showed here

Something confused me a bit more is that if i copy the whole html from inspection and paste it to somewhere like codeply: https://www.codeply.com/p/1mUZYRPstZ its all working fine, the active class is added normally.

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

0

Finally figured it out:

  1. When adding or removing elements in the DOM, you’ll need to call the refresh method. This is from offical doc which I didnt follow
  2. In my local implementation, there is an async fetch call to retrieve blog content and the nav. The async call meets condition of #1, so I need to update scrollspy after element is rendered via useeffect or didMount
  3. This challenge also shows me I cannot always replace the plain html output of jsx with the jsx itself, even the two are identical. You never know if there are any side effect when generating the html via react.
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