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

405
Views
Cómo usar scrollintoview dentro de useeffect (No se pueden leer las propiedades de nulo (leyendo 'scrollIntoView'))

Necesito configurar mi página web de principio a fin. Así que escribo código como este.

 function BasicDetails() { React.useEffect(()=>{ scrollView(); }, []); function scrollView() { document.getElementById('main-root').scrollIntoView({behavior: 'smooth'}); } return ( <Nav> <div id="main-root" style={{scrollBehavior: 'smooth'}}> <div> <Header pageTitle={'Shop Settings'}/> <Button onClick={saveBasicDetails} variant="contained" id='save' className={classes.saveButton}> SAVE </Button> </div> <BasicDetailsData style={{scrollBehavior: 'smooth'}} ref={childRef}/> </div> </Nav> ); }

Pero cuando intenté ejecutar mi código, tengo un error TypeError: No puedo leer las propiedades de nulo (leyendo 'scrollIntoView') Así que lo intenté muchas veces pero no puedo encontrar el error. Soy un nuevo estudiante para reaccionar, así que. No sé mucho al respecto. Cualquiera puede ayudarme con esto... Realmente necesito su ayuda... gracias.

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

0

Probé esto y así es como conseguí que funcionara:

 function scrollView() { const mainRoot = document.getElementById("main-root"); mainRoot.scrollIntoView({ behavior: "smooth" }); }

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!