title: How can I use a function from another file in react?
body: <p>I would like to create a file (function.js) for a function that does this:</p>
  
  <pre><code>let i = 0;
      if (this === that) {
          i = 0;
      } else {
         i = 1;
      }
  </code></pre>
  
  <p>I would then like to add it to (this.js)</p>
  
  <pre><code>import function from "./function";
  class Example extends Component {
      state = {
          test
      };
      render() {
          function()
      return (
          &lt;div&gt;
              &lt;h1&gt;{this.state.test.sample[i].name}&lt;/h1&gt;
          &lt;/div&gt;
  </code></pre>