title: Is there a way to export setState outside stateless components in react?
body: <p><strong>Consider this example</strong></p>
  <pre><code>export function InsideHoc(props){
     const [A, setA] = useState(false);
  
     return({if(A) &amp;&amp; (&lt;h1&gt;Print something&lt;/h1&gt;)});
  }
  </code></pre>
  <p><strong>In another file</strong></p>
  <pre><code>import {A, setA} from './inside-file';
  
  function ToggleFromOutside(){
     return(&lt;p onClick={setA(!A)}&gt;Verify&lt;/p&gt;);
  }
  </code></pre>
  <p>Can setA be exposed outside so that the state of this component be changed from outside? I know this can be done through redux. But without using this, is there a way to change the state of one component?</p>
  <p><strong>Structure is like this</strong></p>
  <pre><code>import {withCreateHOC} from './external';
  import childComponent from './child';
  
  
  class A extends React.Component {
     render(){
        &lt;Another menus={(item) =&gt; &lt;MenuItems object={item} /&gt;}
         /&gt;
     }
  }
  
   export default withCreateHOC(A, {custom: childComponent, title: 'Add'});
  </code></pre>
  <p>//withCreateHOC renders modal here as well as it has a button to toggle the state. Same state should be used from below function</p>
  <pre><code>function MenuItems(){
     return(&lt;button onClick={displayModal}&gt;)
  }
  </code></pre>