title: How can I get the variable from other function to another component on React?
body: <p>Is that possible to use a variable of different function in another component ? I seperated function part and component part that is like :</p>
  <p><a href="https://i.stack.imgur.com/ZrvZh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZrvZh.png" alt="design structure" /></a></p>
  <p>and my function:</p>
  <pre><code>export function createCombos(number_of_cells) {
    number_of_cells = parseInt(number_of_cells);
    const real_number = Math.sqrt(number_of_cells);
    const arr = Array(real_number)
      .fill(0)
      .map((x) =&gt; Array(real_number).fill(0));
  }
  
  </code></pre>
  <p>I want to use &quot;arr&quot; which I declared in &quot;createCombos&quot; function.</p>
  <p>The component that I wanted to use in :
  <a href="https://i.stack.imgur.com/4CzpB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4CzpB.png" alt="Board.js" /></a></p>
  <p>I want to use like that :</p>
  <pre><code>import { createCombos } from &quot;../functions/Combo&quot;;
  import { useEffect, useState } from &quot;react&quot;;
  export default function Board() {
    var [arra, setArra] = useState([]);
    useEffect(() =&gt; {
      createCombos(prompt(&quot;enter a number:&quot;));
       **setArra(createCombos.arr);**
    });
    return &lt;div&gt;
       **arra.map((a)=&gt; { 
          &lt;p&gt; {a} &lt;/p&gt; 
           })**
      &lt;/div&gt;;
  }
  </code></pre>
  <p>How can I do that? Thanks!</p>