Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6213

Using Animated Value in React Native Typescript

$
0
0

I'm trying to write a react native component in typescript that has a Animated.View from the Animated API in the render function.

I'm having an issue setting the Animated.Value as a property of the React Component.

My current code is as follows:

interface NotificationProps {animation : Animated.Value...}class Notification extends React.Component <NotificationProps,NotificationState> {  constructor (props: NotificationProps) {      super(props)      this.props.animation = new Animated.Value(0)      ...      this.state = {...}

However, the ts linter produces the error:

Cannot assign to 'animation' because it is a read-only property

In javascript, simply declaring the Animated.Value in the constructor as below works fine:

this.animation = new Animated.Value(0)

I'm using react native v. 0.61.5


Viewing all articles
Browse latest Browse all 6213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>