Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

82
Views
useCallback not listening my varible change

I want to show popup when my state item is changed, but useCallback not listening my varible "overloaded" change.

const handleOnAddButtonClick = useCallback((e: React.MouseEvent) => {
    if(overloaded){
      openModal({
        modalId: "error-modal",
        props: {
          description: "SSS",
          info: "",
          buttonOnClick: closeAllModal,
          buttonText: "SSS",
        },
      })
    }
    e.stopPropagation();
    e.preventDefault();
    if (storeSearch) {
      router.push(`/store/${item.category.id}?itemId=${item.id}`);
      return;
    }
    handleAddBasket();
    errModal()
  }, [overloaded])

overloaded is change but handleOnAddButtonClick doesn't rerun

const addItemToBasket = createEffect<Partial<BasketItemDto>, void>(
  async (data) => {
    try {
      const item: IResponse<BasketItemDto> = await makeRequest(
        addBasketRequest(data)
      );
    } catch (error) {
      setOverloaded();
      return error;
    }
  }
);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!