title: How to pass function as props in React?
body: <p>I have functional component GetWeather which I want to pass result of  GetLocation function as props based on which GetWetaher will do something i.e. another get request (in the example below it only renders its props). I think it has to happen inside ComponentDidMount, not sure how to do it</p>
  
  <pre><code>    function GetLocation() {
          axios.get('http://ipinfo.io')
            .then((res) =&gt; {      
              return res.data.loc;
            })
  
        }
      function GetWeather(props) {
      //more code here, including another get request, based on props
          return &lt;h1&gt;Location: {props.location}&lt;/h1&gt;;    
      }
  
      class LocalWeather extends Component {           
        componentDidMount() {    
          //???     
        }          
        render() {
          return (
            &lt;div &gt;                         
                  &lt;GetWeather location={GetLocation}/&gt; //???                                               
            &lt;/div&gt; 
          );
        }
      }
  </code></pre>
  
  <p><strong>Update:</strong> So based on suggestion from Damian below is working for me</p>
  
  <pre><code>function GetWeather(props) {   
      return &lt;h3&gt;Location: {props.location}&lt;/h3&gt;;   
  }
  
  class LocalWeather extends Component {
    constructor(props) {
      super(props);
      this.state = {
        location: []
      }; 
    }
    getLocation() {
      axios.get('http://ipinfo.io')
        .then((res) =&gt; {       
          this.setState({location:res.data.loc});        
        })         
    }
  
    componentDidMount() {    
      this.getLocation();     
  
    }
    render() {
      return (
        &lt;div &gt;                       
              &lt;GetWeather location={this.state.location}/&gt;                                                 
        &lt;/div&gt; 
      );
    }
  }
  </code></pre>