title: How do I access React component's local state using Cypress?
body: <p>I'm using react with redux and testing with cypress,
  I was able to access the store using 
  cy.window().its('store').invoke('getState').then((state) => {}
  But how do i access a component's local state rather than the application store?</p>
  
  <p>I tried </p>
  
  <pre><code>cy.get('.simple-component').its('getState')
  </code></pre>
  
  <p>or </p>
  
  <pre><code>cy.get('.simple-component').invoke('getState')
  </code></pre>
  
  <p>but Cypress is returning "CypressError: Timed out retrying: cy.invoke() errored because the property: 'getState' does not exist on your subject" 
  And on the Cypress console (in chrome) it's yeilding:</p>
  
  <pre><code>Yielded:   
  &lt;div class="simple-component" getstate="[object Object]"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>It seems that's caused by React removing the methods from the DOM so i need to access it in React rather than in the DOM?</p>
  
  <pre><code>import React, { Component } from 'react';
  
  class simpleComponent extends Component {
      constructor(props) {
          super(props)
          this.state = {
              sample: "hello"
              }
      }
      // getState() just for testing on cypress
      getState() {
        return this.state
      }
      render(){
        return &lt;div className="simple-component" getState={this.getState()}&gt;&lt;/div&gt;
      }    
  }
  </code></pre>
  
  <p>As an alternative can i export the local component state at the end of the simple-component using window.store?</p>