Next.js Discord

Discord Forum

Race Condition Problem

Unanswered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
Hey guys, I think I'm having some kind of racing condition problem:

  const getAccounts = useCallback(async () => {
    const result = await fetchInstance(
      `${MainService.URL}${MainService.Accounts}`,
      {
        headers: { Authorization: `Bearer ${jwt}` },
      },
      jwt,
      refreshToken
    );

    if (result === null) {
      goToAuth();
    }

    if (!result.response.ok)
      console.error("something went wrong while trying to get the accounts");

    const accountsResponse: Account[] = await result.response.json();

    setAccounts(accountsResponse);
  }, [jwt, refreshToken, setAccounts, startOnboarding]);

  useEffect(() => {
    getAccounts().then(() => startNextStep("accountTour"));
  }, []);


I'm trying to run startNextStep from the package nextstepjs after fetching some data, but it is glitching my page and I don't really know why, does someone know what can I do? Thanks!

0 Replies