State hook not changing boolean value

In the code below I am having an issue.

I was trying to implement doubleClick behavious and the state hook for the boolean changes to trigger it. The problem is that even though handleDoubleClick function is triggered, setAllowSingleClick is not changing the value to false so than anyway the handleClick funtion is getting triggered.

    const CLICK_DELAY_TIME = 200;
    const [allowSingleClick, setAllowSingleClick] = useState(true);
    let timer = 0;
    
      const handleClick = () => {
        timer = setTimeout(() => {
          if (allowSingleClick) {
            doSMTH1()
          }
        }, CLICK_DELAY_TIME);
      };
    
      const handleDoubleClick = () => {
        clearTimeout(timer);
        setAllowSingleClick(false);
        doSMTH();
      };

    <div
      onClick={handleClick}
      onDoubleClick={handleDoubleClick}
    >