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

250
Views
How to make ScrollView automatically go back to origin?

I have a ScrollView like this:

const CustomComp=React.memo(({props...})=>{
 return(<ScrollView horizontal={true}>
   {content...}
 </ScrollView>);
});

and when I scroll to the right and then re render, the x position of the Scroll stays the same

enter image description here

how do I get it to go back to x=0 every time it re renders?

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

0

You can use useEffect hook and ScrollView's scrollTo method.

Here is a snack to test it: https://snack.expo.dev/@truetiem/scroll-to-top-when-re-rendered

First create a ref for scroll view.

const scrollRef = useRef();

<ScrollView ref={scrollRef} horizontal>

And scroll to top when useEffect triggered.

useEffect(() => {
  scrollRef.current?.scrollTo({ x: 0, y: 0, animated: true });
});
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!