title: ReactJS: How to export variables from useState hook?
body: <p>Earlier, data in the json format was stored in the data.js file, now it was necessary to load them from the server. I would not want to change the logic of the file into which these data variables are imported. How can I correctly export these two variables to product.js file? 
  Thanx a looot! [![enter image description here][1]][1]</p>
  
  <p>links and screen: </p>
  
  <pre><code>import React, {useEffect, useState} from "react";
  import ReactDOM from "react-dom";
  import axios from'axios'
  function Product() {
    const [storeProducts, setStoreProducts] = useState({ hits: [] });
    const [detailProduct, setDetailProduct] = useState({ hits: [] });
    useEffect(() =&gt; {
      const fetchDataProducts = async () =&gt; {
        const result = await axios(
          'https:/api/v1/products/',
        );
        setStoreProducts(result.data)
        console.log(result.data);
      };
      fetchDataProducts();
        }, []);
    useEffect(() =&gt; {
      const fetchDataProduct= async () =&gt; {
        const result = await axios(
          'https://api/v1/products/:id',
        );
        setDetailProduct(result.data);
      };
      fetchDataProduct();
        }, []);
  }
  
  How to export storeProducts and detailProduct?
  
  </code></pre>
  
  <p>for clarity, add a link
    <a href="https://jsfiddle.net/constant101/br0L4a2n/1/" rel="nofollow noreferrer">https://jsfiddle.net/constant101/br0L4a2n/1/</a></p>
  
  <p><a href="https://jsfiddle.net/constant101/br0L4a2n/2/" rel="nofollow noreferrer">https://jsfiddle.net/constant101/br0L4a2n/2/</a></p>