/    Sign up×
Community /Pin to ProfileBookmark

Toggling a recursive fetch request in React using `useEffect`

Hello,

I’ve posted a React question on StackOverflow but it seems to have been lost under the many thousands of questions being asked on the site each day. I have received valuable help from this great community before so I’m hoping someone is willing to tackle my problem. 🙂

In short, I’m trying to toggle a recursive `fetch` request whenever a specific state changes in React. I’ve included the additional details in the [StackOverflow question](https://stackoverflow.com/questions/69597760/toggling-a-recursive-fetch-request-based-on-react-state-using-useeffect).

Thank you in advance!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@boohooOct 17.2021 — Since it's just a second, do you think it would be an acceptable simplification to have the setTimeout() working no matter what and only fetching if the value is what you want it to be?
Copy linkTweet thisAlerts:
@looky1173authorOct 17.2021 — @boohoo#1638268 It's not necessarily one second as it is a dynamic value controlled by a state. I just didn’t want to make my question more complicated than it needs to be on SO. By the way, I'v found a (lengthy) solution which I will post as soon as I find the time. (I'm writing from a mobile device 🙂)
×

Success!

Help @looky1173 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...