title: How can I conditionally do POST request in React?
body: <p>First, please look at the code.</p>
  <pre class="lang-js prettyprint-override"><code>    const [detailTitle, setDetailTitle] = useState(actionItemArray[activeRow].TITLE);
      const [detailDesc, setDetailDesc] = useState(actionItemArray[activeRow].DESCRIPTION);
  
      //Unix time 변환 함수
      function getUnixTime(t) {
          const date = new Date(t * 1000);
          const year = date.getFullYear();
          const month = '0' + (date.getMonth() + 1);
          const day = '0' + date.getDate();
          return year.toString().substr(-2) + '-' + month.substr(-2) + '-' + day.substr(-2);
      }
  
      const [detailStartDate, setDetailStartDate] = useState(getUnixTime(actionItemArray[activeRow].START_DATE));
      const [detailDueDate, setDetailDueDate] = useState(getUnixTime(actionItemArray[activeRow].DUE_DATE));
  
      const [detailPriority, setDetailPriority] = useState(actionItemArray[activeRow].P_PK);
      const [detailStep, setDetailStep] = useState(actionItemArray[activeRow].STEP_PK);
  
      const [disabled, setDisabled] = useState(true);
      const [disableTag, setDisableTag] = useState(true);
  
      const detailTitleChange = (e) =&gt; {
          setDetailTitle(e.target.value);
      };
  
      const detailDescChange = (e) =&gt; {
          setDetailDesc(e.target.value);
      };
  
      const detailStartDateChange = (e) =&gt; {
          setDetailStartDate(e.target.value)
      };
  
      const detailDueDateChange = (e) =&gt; {
          setDetailDueDate(e.target.value)
      };
  </code></pre>
  <p>and for Priority and Step, I gave onChange event as it is a Select Form.</p>
  <pre class="lang-js prettyprint-override"><code>    const updateActionItem = () =&gt; {
          const url = '/api/work/update-action-item';
          const data = {
              ACTION_PK : actionItemArray[activeRow].ACTION_PK,
              OWNER_PK : actionItemArray[activeRow].owner.USER_PK,
              TITLE : detailTitle,
              DESCRIPTION: detailDesc,
              START_DATE : detailStartDate,
              DUE_DATE : detailDueDate,
              P_PK : detailPriority,
              STEP_PK : detailStep,
              updateCols: ['TITLE', 'DESCRIPTION']
          };
          post(url, data)
          .then((res) =&gt; {
              alert('수정되었습니다');
              console.log(res);
          })
          .catch((error) =&gt; {
              console.log(error)
          });
      };
  </code></pre>
  <p>this function is for a POST request. I send every edited data to DB.</p>
  <p>But data object, you can see updateCols : [].</p>
  <p>In this array, I have to put properties that have been changed.</p>
  <p>For example, If I change TITLE, DESCRIPTION and START_DATE, I have to change the array to</p>
  <pre class="lang-js prettyprint-override"><code>updateCols : ['TITLE', 'DESCRIPTION', START_DATE]
  </code></pre>
  <p>I am having trouble with this POST request form as I think it is impossible to track things down every time.</p>
  <p>Someone might edit only TITLE, someone might edit every property. That means I have to change POST request form conditionally.</p>
  <p>I need some wisdom. Please Help!</p>