title: Can not find Variable in react-native
body: <p>I am trying to build an app in react native and keep having an error titled <code>Cannot find variable: opacity</code> in a feature that should fade an image in and then fade an image out depending on the user pressing a button. </p>
  
  <p>I have tried multiple things such as using the <code>let</code> operator and trying to change where the code is located in the class.</p>
  
  <p>here is the code for the button and animation</p>
  
  <pre class="lang-py prettyprint-override"><code>import React, { Component } from "react";
  import {
    Image,
    Animated,
    Easing,
    StyleSheet,
    TouchableWithoutFeedBack
  } from "react-native";
  
  const styles = StyleSheet.create({
    info: {
      // for info button
      height: 50,
      width: 50,
      flex: 1,
      position: "absolute",
      left: 315,
      bottom: -675
    }
  });
  
  class Info extends Component&lt;Props&gt; {
    state = { opacity: new Animated.Value(0) };
    infoScale = opacity.interpolate({      
        inputRange: [0, 1],
        outputRange: [0.85, 1],
    });
    transformStyle = {
      ...styles.image,
      transform: [{ opacity: infoScale }]
    };
    render() {
      return (
        &lt;TouchableWithoutFeedBack
          onPressIn={() =&gt; {
            scaleValue.setValue(0);
            Animated.timing(opacity, {
              toValue: 1,
              duration: 250,
              easing: Easing.linear,
              useNativeDriver: true
            }).start();
          }}
          onPressOut={() =&gt; {
            Animated.timing(opacity, {
              toValue: 0,
              duration: 100,
              easing: Easing.linear,
              useNativeDriver: true
            }).start();
          }}
        &gt;
          &lt;Image
            source={require("../assets/images/info2.png")}
            style={styles.info}
            resizeMode="contain"
          /&gt;
          &lt;Animated.View style={transformStyle}&gt;
            &lt;Image source={require("../assets/images/iPhoneTimeTreeInfo.png")} /&gt;
          &lt;/Animated.View&gt;
        &lt;/TouchableWithoutFeedBack&gt;
      );
    }
  }
  
  export default Info;
  </code></pre>