question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with AnimateStyle<> typing

See original GitHub issue

While the typing supports perfectly top-level properties and style properties (kudos to that because the RN Animated API types them as any), there seems to be an issue with transform properties which are one level of nesting deeper.

For instance:

const scale = new Value(1);
const opacity = new Value(1);
<Animated.View style={{ opacity }} /> // Work great
<Animated.View style={{ transform: [{ scale }] }} /> //  type error

I looked at the type definition AnimateStyle in react-native-reanimated.d.ts but this type definition is challenging for me to understand. I would love to help to solve this issue if pointed to the right direction though.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
prithweedascommented, Sep 29, 2019
const Example = () => {
  const { translationX, gestureHandler } = horizontalPanGestureHandler()
  return (
    <View style={styles.container}>
      <PanGestureHandler {...gestureHandler}>
        <Animated.View style={{ transform: [{ translateY: translationX }] }} />
      </PanGestureHandler>
    </View>
  )
}

And here’s the type error I’m getting error

0reactions
hastomcommented, Apr 6, 2020

Same issue

const Test = () => {
  <Animated.View style={{ transform: [ { translateX: new Animated.Value(0)} ] }} />
}

Gives error Type 'Animated.Value(0)' is not assignable to type 'number'

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with AnimateStyle<> typing #297 - GitHub
I looked at the type definition AnimateStyle in react-native-reanimated.d.ts but this type definition is challenging for me to understand. I ...
Read more >
Unsure what type my prop is in react native typescript
I am trying to implement typescript into my project and I am having issues giving prop types to my swipe prop.
Read more >
How to Create a Typing Effect in Canva - YouTube
HOW TO CREATE A TYPING EFFECT IN CANVA | CANVA VIDEO ANIMATION TUTORIAL If you are looking for a fun animated video effect...
Read more >
Advanced "Fall in place" typewriting effect? - DevForum | Roblox
I know how to make a basic typewriter effect, but I want to achieve this unique effect and going through the posts I...
Read more >
Animate.css | A cross-browser library of CSS animations.
Animate.css is a library of ready-to-use, cross-browser animations for you to use in your projects. Great for emphasis, home pages, sliders, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found