DEV Community

Discussion on: Avoiding Race Conditions when Fetching Data with React Hooks

Collapse
 
talha131 profile image
Talha Mansoor

Hi @nas5w . Thanks for writing this article. Great use of the useEffect cleaner.

I think another way to resolve this issue is to keep the buttons disabled until the promise is resolved or rejected. This will make for a less confusing UX. User will not be able to click the conflicting buttons to being with.

Collapse
 
nas5w profile image
Nick Scialli (he/him)

Thanks! I think in this example, however, you wouldn’t want to prevent someone from navigating to another user’s profile just because a fetch request hasn’t returned. The user should be able to freely navigate the application regardless of whether the fetch request has resolved.