title: Accessing this.state value to other Class [React Native]
body: <p>I just wanna ask how can i access this.state.sampleString from other class.. Here's my code</p>
  
  <pre><code>class MainClass extends Component {
  
    constructor(props){
        super(props)
  
  
        this.state = {
          sampleString: 'Test String'
        }
  
        this.getValue = this.getValue.bind(this);
      }
  
  
      getValue(){
          //console.log(this.state.sampleString);
          return this.state.sampleString
      }
  
  }
  </code></pre>
  
  <p>=========</p>
  
  <p>This is my function from My second class to get the value of "this.state. sampleString" from MainClass</p>
  
  <pre><code>function getValueFromMainClass() {
  
    var stringFromClassHeader = () =&gt; {HeaderWithBg.getValue()}
  
    console.log(stringFromClassHeader.sampleString);
  
  }
  </code></pre>
  
  <p>Why it returns "undefined"?</p>
  
  <p>Thanks alot. Im a new in react native.</p>