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

296
Views
Desplazamiento automático de reacción para mostrar los datos obtenidos

Soy nuevo en reaccionar y estoy tratando de desplazarme automáticamente a la Sección donde se mostrarán los datos después de obtenerlos

el desplazamiento debe ser después de que se obtengan los datos

 const App = () => { const [Data ,setData] = useState([]) const [InputTracking , setInputTracking] = useState('') const [isLoading,setIsLoading] = useState(false) const [Clicked , setClicked] = useState(false) //button onClick function const searchTrackingID = async (TrackingID) => { console.log(TrackingID) setIsLoading(true); const response = await axios(API_URL+TrackingID) ; const res = await response.data ; setData(res) setIsLoading(false); setClicked(true); } } return ( <Header /> //here a form with a text input and button (after clicking it , wait for Data to change state then AUTO SCROLL TO Data (section) <section > <div > <div > { Data.slice(1).reverse().map((mydata)=>( <TrackingInfo Maindata={mydata}/> )) } </div> </div> </section> )
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

function TestComponent() { const testRef = useRef(null); const scrollToElement = () => testRef.current.scrollIntoView(); useEffect(()=>{ if(loading){ scrollToElement() } }, [loading]) // Once the scrollToElement function is run, the scroll will show the element return ( <> <div ref={testRef}>Element you want to view</div> </> ); }

Referencia: https://www.delftstack.com/howto/react/scroll-to-an-element-in-react/

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!