Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
Flatlist Scrolling to initalScrollIndex after rendering

For some reason my Flatlist first renders and then Scrolls to the initalScrollIndex
I recorded it and it looks like this and if you watch it carefully

Frame 1
enter image description here

Frame 2
enter image description here

Code:

const Am_pm_DATA=[{ key: 0, title: '' }, { key: 1, title: 'am' }, { key: 2, title: 'pm' }, { key: 3, title: '' }];

const [FromAmPm, setFromAmPm] = useState(() => 1);

const ItemComp = ({ item }) => (
  <View
    style={...}>
    <Text style={...}>{item.title}</Text>
  </View>
)

return(<>  
         <FlatList
            initialScrollIndex={FromAmPm}
            data={Am_pm_DATA}
            renderItem={ItemComp}
            keyExtractor={(_, index) => index.toString()}
            getItemLayout={(_, index) => {
                return { length: CustomStyle.height, offset: CustomStyle.height * index, index };
            }}
            showsVerticalScrollIndicator={false}
            snapToOffsets={Am_pm_DATA.map((x, i) => (i * CustomStyle.height))}
        />
        <View style={...} pointerEvents="none"></View>
</>);

how do I make the flatlist render already at the initalScrollIndex position ?
I tried this but it doesn't seem to help

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda