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

125
Views
Carousel react native firstItem doesn't update dynamically

I have a problem with Carousel which is implemented like this:

<Carousel
          key={3}
          sliderWidth={device.windowWidth}
          sliderHeight={device.windowHeight}
          activeSlideAlignment="start"
          itemWidth={device.windowWidth-20}
          data={picklistItems}
          firstItem={props.selectedPinkItemIndex ? props.selectedPinkItemIndex : 0}
          scrollEnabled={true}
          pointerEvents={'none'}
          lockScrollWhileSnapping

the problem which I'm facing is that firstItem 'doesn't see' that the state (props.selectedPinkItemIndex) updates - when I console.log the props.selectedPinkItemIndex, it is a few times 0, and then it updates to for example 8, but the Carousel kinda doesn't see that the state updated and I'm always stuck at 0. Obviously if I make firstItem={8} it propely shows the 8th item, but dynamically, it doesn't work.

The selectedPinkItemIndex is set in parent's component like this:

const [initialPicklistItemIndex, setInitialPicklistItemIndex] = useState<number>(0);

and then passed to carousel's component like this:

selectedPinkItemIndex={initialPicklistItemIndex}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you're using react-native-snap-carouse try using

snapToItem(index, animated = true)

instead.

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!