79385618

Date: 2025-01-24 21:05:20
Score: 0.5
Natty:
Report link

Turns out throttle() from lodash was the correct way to go. To solve this problem I ensured that the options for the trailing edge were set to false:

const handleClick = _.throttle(
    (index: number) => {
      if (active === undefined) {
        setActive(index);
        return;
      }

      setActive(undefined);
    },
    200,
    { trailing: false },
  );
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Finn Formica