title: ReferenceError: Cannot access 'x' before initialization in React hook
body: <p>I'm having some trouble with a piece of code in React.</p>
  <p>I've created a gh repo that reproduce the error : <a href="https://github.com/AnatoleLucet/next-issue" rel="nofollow noreferrer">https://github.com/AnatoleLucet/next-issue</a></p>
  <p>I'm trying to do a hook that gets some local data (in my real app it's a translation system, but you get the idea). Thing is, I pass each &quot;part&quot; of my data (see <code>data/myData.ts</code> and <code>data/index.ts</code>) in a function called <code>formatData</code>, this function is declared in the same file as my hook (<code>hooks/myHook.ts</code>). Then when I use my hook in a component (see <code>pages/index.tsx</code>) I get the following error :</p>
  <p><img src="https://i.stack.imgur.com/Lbnji.png" alt="" /></p>
  <p>I don't understand why the browser (or webpack ?) doesn't initialize <code>formatData</code> at the right time...</p>
  <p>I'm using Nextjs but I don't think it's related to the issue, although I haven't tried on a &quot;vanilla&quot; React project.</p>
  <p>As a temporary fix, I can move <code>formatData</code> to another file like <code>utils/data.ts</code>.</p>