title: Can I pass props to a React Component from a general function?
body: <pre><code>   import B from './B.js'; 
     const Test = () =&gt; {
        
        async function getResults() {
          await axios
            .get(`http://localhost:2000/?url=${link}`)
            .then((response) =&gt; {
              &lt;B data={response.data} /&gt;
            });
        }
        return (
          &lt;&gt;
            &lt;div&gt; 
             &lt;button onClick={getResults}&gt; Click &lt;/button&gt;
           &lt;/div&gt;
          &lt;/&gt;
            )
  </code></pre>
  <p>I was trying to pass the axios data as props to my component B. But in console I got undefined value. How to solve this issue. Should I pass the props inside the return area of the Test Component only?</p>