Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
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 Respuestas
Responde la pregunta

0

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

snapToItem(index, animated = true)

instead.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda