title: How to use variables across files in React JS
body: <p>So I have set two datepickers which needs to be reformatted to MM-YYYY which I done with the following code:</p>
  <pre><code>const [dateFrom, setDateFrom ] = useState('2012-01-01')
  const [dateTill, setDateTill ] = useState('2012-12-31')
  
  const [yearFrom, monthFrom, dayFrom] = dateFrom.split('-');
  const newDateFrom = `${monthFrom}-${yearFrom}`
  const [yearTill, monthTill, dayTill] = dateTill.split('-');
  const newDateTill = `${monthTill}-${yearTill}`
  export default {newDateFrom, newDateTill}
  </code></pre>
  <p>I want to use the newDateFrom and newDateTill variables in my api file located in my api folder. I have used string interpolation here.</p>
  <p>export const fetchTimeData = async () =&gt; {</p>
  <pre><code>const response = await fetch(`https://api.punkapi.com/v2/beers?brewed_before=${newDateTill}&amp;brewed_after=${newDateFrom}&amp;per_page=80`)
  const data = await response.json();
  
  return data
  </code></pre>
  <p>}</p>
  <p>How can I get this to work? I'm not sure if props would work as there isn't a parent-child relationship going on here?</p>
  <p>Thank you</p>