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

232
Visualizações
Why does using Animated.createAnimatedComponent(Pressable) breaks my Pressable functionality?

I'm trying to animate a Pressable component which is why I'm trying to make it animatable like this:

const AnimatedPressable = Animated.createAnimatedComponent(Pressable);

And then use it instead of this:

    <Pressable
        style={({ pressed }) => [
            styles.button,
            styles[variant],
            { width, elevation: pressed && variant !== 'tertiary' ? 5 : 0 },
            { ...(variant === 'tertiary' && pressed ? { backgroundColor: colors.primary50 } : {}) },
            style,
        ]}
        {...rest}
    >
        <HeaderText variant="h4" style={[styles.text, { color: textColor }]}>
            {title}
        </HeaderText>
    </Pressable>

The problem is that as soon as I replace Pressable with AnimatedPressable, my styles break. After fiddling a bit, I realised that they break because of this:

    style={({ pressed }) => [
        styles.button,
        styles[variant],
        { width, elevation: pressed && variant !== 'tertiary' ? 5 : 0 },
        { ...(variant === 'tertiary' && pressed ? { backgroundColor: colors.primary50 } : {}) },
        style,
    ]}

If I remove the pressed, it works fine:

    style={[
        styles.button,
        styles[variant],
        style,
    ]}

Why can't I use pressed in that case?

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