title: how to append 2 usestates in react js
body: <p>i have 2 useStates i want to append both when i call  <code>SubmitData</code>
  <code>allValues</code>  has many datas name ,age ,sex etc..  i want add   <code>domestic</code> also into allvalues</p>
  <pre><code>  const changeHandler = (e) =&gt; {
      setAllValues({ ...allValues, [e.target.name]: e.target.value });
    };
  
     const SubmitData = () =&gt; {
      console.log(domestic);
      
      const formData = { ...allValues };
      if (!domestic) {
        formData.domestic = domestic;
      }
      var custumer = parseInt(id);
      if (!custumer) {
        formData.customer = custumer;
      }
  </code></pre>
  <p>when  allValues is empty and i only pass value of <code>domestic</code> i am getting  the floowlowing error</p>
  <p><code>TypeError: Cannot set properties of undefined (setting 'domestic')</code></p>