title: setAttribute onClick function - React JS
body: <p>I have 2 functions - addBookmark() and removeBookmark.</p>
  
  <p>I have vaiable IsBookmakred that is true or false. Part of my JSX containing bookmark is:</p>
  
  <pre><code>  {props.singleCompany.IsBookmarked ? (
        &lt;div&gt;
          &lt;span
            className="fa fa-star bookmarked"
            onClick={removeBookmark}
            data-tip="Remove Bookmark"
          &gt;&lt;/span&gt;
          &lt;ReactTooltip /&gt;
        &lt;/div&gt;
      ) : (
        &lt;div&gt;
          &lt;span
            className="fa fa-star"
            onClick={addBookmark}
            data-tip="Add Bookmark"
          &gt;&lt;/span&gt;
          &lt;ReactTooltip /&gt;
        &lt;/div&gt;
      )}
  </code></pre>
  
  <p>As you see I am using both functions addBookmark nad removeBookmark as per situation. I need to be able to change this  attributes if bookmark is true or false (when it is clicked). Here is 1 of my functions for example without POST request:</p>
  
  <pre><code>    const addBookmark = e =&gt; {
      console.log(e.target);
      const data = {
        userGuid: sessionStorage.getItem("Guid"),
  
        smallPlanID: props.singleCompany.SmallCompanyPlanID,
  
        largePlanID: props.singleCompany.LargeCompanyPlanID
      };
      e.target.classList.add("bookmarked");
      e.target.onclick = removeBookmark();
  
      //POST REQUEST IS HERE...
    };
  </code></pre>
  
  <p>As you can see  e.target.onclick = removeBookmark(); is not the thing I want. This is just to show my idea what has to happen. I tried:</p>
  
  <pre><code>e.target('onclick','doSomething();');
  </code></pre>
  
  <p>also but without success. How should I change my onClick attribute to point to other function?</p>