title: Pass reference as default for specific function JS
body: <p>Consider this:</p>
  
  <pre><code>function helperFunction (text, setState) {
      setState({
          value: "some value",
          text: text
      });
      return "result";
  }
  
  function mainFunction (state, setState) {
      switch (state.value) {
          case "" : return helperFunction("empty string", setState);
          case "aaa" : return helperFunction("the string is aaa", setState);
          case "bbb" : return helperFunction("the string is bbb", setState); 
          case ...
          default ...
      }
  }
  </code></pre>
  
  <p>These functions are in external file so I have to pass setState reference in order to be able to update the state (via useReducer/useState Hooks). </p>
  
  <p><code>helperFunction</code> is a helper function, and I want to optimize this code and get rid of necessity of passing <code>setState</code> reference to it <strong>every time/case</strong>, which is always the same for the <code>mainFunction</code>.</p>
  
  <p>How do I can pass setState to <code>helperFunction</code> as a default for the <code>mainFunction</code>?</p>
  
  <p>To be clear</p>
  
  <p>I want: </p>
  
  <pre><code>case "aaa" : return helperFunction("the string is aaa");
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>case "aaa" : return helperFunction("the string is aaa", setState); 
  </code></pre>
  
  <p>What is the "best practices" for this case?</p>
  
  <p>PS: <code>helper</code> is a universal, and I need to be able to change its defaults depending on function that is running it.</p>
  
  <p>Update: some answers suggest to put it inside the mainFunction - I can't do this, helper is a universal function, any function should be able to run it.</p>