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

134
Views
Desplácese a la sección en Reactjs usando jQuery

Tengo una aplicación reactjs con múltiples componentes,

 function App() { return ( <main className="text-white"> <Navbar /> <About /> <Skills /> <Experience /> <Project /> <Contact /> </main> ); }

¿Cómo puedo usar jQuery dentro del componente de la barra de navegación para desplazarme a estas secciones? ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Un paquete como este puede ayudarte con eso. Usar Jquery o cualquier API DOM en su código React es una mala práctica y debe evitar hacerlo.

about 4 years ago · Juan Pablo Isaza Report

0

Realmente no necesitas JQuery. Puede hacer esto usando atributos HTML y CSS. Simplemente adáptelo al marco React.

  1. Dar a cada sección una identificación
  2. Haz que los elementos de navegación sean etiquetas <a>
  3. Agregue la ID de cada sección como la propiedad href de su respectiva etiqueta <a>
  4. En el CSS, agregue scroll-behaviour: smooth a la etiqueta <html> .

Ejemplo:

 html { scroll-behavior: smooth; height: 2600px; overflow: auto; display: flex; flex-direction: column; justify-content: space-between; } p { margin: 200px 0; }
 <div> <a href="#about">About</a> <a href="#skills">Skills</a> </div> <div> <p id="about">This is about text</p> <p id="skills">This is skills text</p> </div>

PERO...

Si realmente quieres usar JQuery, puedes hacerlo así:

 function scrollToSection(sectionID) { $('html, body').animate({ scrollTop: $(sectionID).offset().top }, 400); }
 html { height: 2600px; overflow: auto; display: flex; flex-direction: column; justify-content: space-between; } .btn { display: inline-block; cursor: pointer; color: blue; text-decoration: underline; } p { margin: 200px 0; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div> <div class="btn" onclick="scrollToSection('#about')">About</div> <div class="btn" onclick="scrollToSection('#skills')">Skills</div> </div> <div> <p id="about">This is about text</p> <p id="skills">This is skills text</p> </div>

about 4 years ago · Juan Pablo Isaza 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!