title: How do I share a global variable between multiple files?
body: <p>I have two files that both need a global variable. I have a click button. When it's clicked, runs a function. The code looks like this:</p>
  
  <p>file1:    </p>
  
  <pre><code>var globalVar = '', // The global variable
  
  &lt;button onClick = {() =&gt; this.edit(arg1)}&gt;&lt;/button&gt;
  function edit (arg1){
  
     globalVar = arg1;
  }
  
  module.exports = globalVar;
  </code></pre>
  
  <p>I have another file, looks like this: </p>
  
  <p>file2:</p>
  
  <pre><code>var globalVar = require(./file1);
  
  function openModal(){
  
  if (globarVar != ''){
   do something
  </code></pre>
  
  <p>}
  }</p>
  
  <p>The issue is that when I click button, the globalVar is updated in the edit() function, but I console.log(globalVar) in file2 it shows ' '.My question is how do I pass the globalVar to file2 when I click the button?</p>