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

113
Visualizações
Cannot read properties of undefined (reading 'interpolate')

I have a flatlist of items that renders a side swipe menu. In the side swipe menu I have a button that allows a user to delete an item from the flatlist. I'm trying to make it so the item animates upward when it gets deleted. To do this I've done:

// Holds all the items animated values
const rowTranslateAnimatedValues = {};
  
  // Delete item by index
  const removeItemById = (inventoryItemIndex) => {
Animated.timing(rowTranslateAnimatedValues[inventoryItemIndex], {
  toValue: 0,
  duration: 200,
}).start(() => {
  // filter down item and set data to state
});
};

// Flatlist of items
<FlatList
        data={inventoryData}
        renderItem={({ item, index }) => (
          <Swipeable
            key={index + 5}
            ref={
              (ref) =>
                (rowTranslateAnimatedValues[index] = new Animated.Value(1))) // create a Animated value ref for every item
            }
            onSwipeableRightOpen={() => closeRow(index)}
          >
            <Animated.View
              style={{
                height: rowTranslateAnimatedValues[index].interpolate({ // causes error
                  inputRange: [0, 1],
                  outputRange: [0, 78],
                }),
              }}
            >
              <Layout level={theme === 'dark' ? '3' : '1'}>
                <InventoryItem item={item} />
              </Layout>
            </Animated.View>
          </Swipeable>
        )}
        keyExtractor={(item, index) => index.toString()}
      />

In the Flatlist, I'm creating an Animated.Value ref for every item. The problem is, when I try to access rowTranslateAnimatedValues[index] in the Animated.View I get the error: Cannot read properties of undefined (reading 'interpolate'). I'm confused by this because on the page load, rowTranslateAnimatedValues is populated with Animated values.

How can I solve this? I've been stuck for a while. Any help would be appreciated.

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