title: How do I call a method from another class component in React.js
body: <p>So I have to class components:<br/>
  Class1: has a clickbutton<br />
  Class2: has a method calling my api<br />
  <br /> 
  Basically, what I want is to call a method that sets and edits states inside one class from another class. But I keep failing.</p>
  
  <h2>Example:</h2>
  
  <pre><code>Class1.js
  export class Class1 extends Component {
     render() {
        return (
           &lt;div onClick={must call Class2Method}&gt;&lt;/div&gt;
        )
     }
  }
  
  Class2.js
  export class Class2 extends Component {
     Class2Method(){
        Here I call my API, I set &amp; call states, ...
     }
     render {
        return (
           &lt;Class1 /&gt;
           Here I return my API content
        )    
     }   
  }
  </code></pre>
  
  <h2>What I tried:</h2>
  
  <ol>
  <li>I have tried to use my method and call and set my states in my App.js (parent of both class2 and class1); but then my Class2.js console says it can't find my states.</li>
  <li>I also tried: &lt; Class1 method={this.Class2Method} /> in my Class 2 and &lt; div onClick={this.props.method} > in Class1.</li>
  </ol>