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

228
Views
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
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!