Core Ui CIcon arrow not getting toggled

I have a CoreUi CIcon cilArrowTop and cilArrowBottom. When I’m trying to toggle it based … Read more Core Ui CIcon arrow not getting toggled

I have a CoreUi CIcon cilArrowTop and cilArrowBottom. When I’m trying to toggle it based on a boolean value, it’s not changing.
Here’s my code:

  const [sortDate, setSortDate] = useState(false)

  const sortPostDate = (response, reverse) => {
    setSortDate(!reverse);
    response.facebook_ads_posts.data.sort((a, b) => {
      if (!reverse) {
        return (
          new Date(b.created_time).getTime() -
          new Date(a.created_time).getTime()
        );
      } else {
        return (
          new Date(a.created_time).getTime() -
          new Date(b.created_time).getTime()
        );
      }
    });
  };

    return(
              <CIcon
                style={{ cursor: "pointer" }}
                onClick={(e) => {
                  e.preventDefault();
                  sortPostDate(response, sortDate);
                }}
                content={
                  sortDate ? freeSet.cilArrowBottom : freeSet.cilArrowTop
                }
              />
          )

I’m unable to figure out the issue. Everything looks fine to me.

Source: React – Stack Overflow


Categories: NewsTags: ,

Tags: ,


Leave a Reply

Your email address will not be published. Required fields are marked *