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

158
Views
Why .current and .props are always undefined in my react native ref?

I want to animate my Animated.View using click event of a dynamic layout. I'm creating the refs like this

In constructor

this.HeadingAnimationRefs = []

then in my component

<Animated.View ref={ref => this.HeadingAnimationRefs[index] = ref}>
    <Text style={styles.boldHeading}>Hello</Text>
</Animated.View>

and on my onPress method

onPress={() => console.log('Hi ', this.HeadingAnimationRefs[index].current)}

or

onPress={() => console.log('Hi ', this.HeadingAnimationRefs[index].props)}

Please tell me the proper way to highlight/animate a view. I've tried using TouchableOpacity but it is not animating when clicked programmatically so I decided to wrap it in Animated.View but now I cannot animate the Animated.View.

Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I was able to animate the view without using the refs like this.

In state I used an array to store anim reference value for my components, then in the onPress method I called the animation function with reference to the index of my respective component.

Animation method

  animateView = (index) => {

    Animated.timing(this.state.questionLocations[questionIndex].anim, {
      toValue: 0,
      duration: 1000,
      useNativeDriver: true,
    }).start(
      () => {
        Animated.timing(this.state.questionLocations[questionIndex].anim, {
          toValue: 1,
          duration: 1000,
          useNativeDriver: true,
        }).start()
      }
    );
  }

and onPress

onPress={() => this.animateView(index)}

and finally set the opacity of Animated.View like this

<Animated.View style={{ opacity: this.state.questionLocations[questionIndex]?.anim }}>
    <Text style={styles.boldHeading}>Hello</Text>
</Animated.View>
about 4 years ago · Juan Pablo Isaza Report
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!