Back to problems

Fix an Async Race Condition in a React Data Fetching Component

Algorithm · Stripe · Medium

Prevent Stale Responses in a React Resource Loader Medium · Topics · Company Tags · Hints A React view renders data for an active resource. The user can switch rapidly between resource identifiers. The current component requests new data whenever itemId changes, but it has a race condition. If the user opens "doc-12" and immediately opens "doc-77", the first request may finish last and overwrite the data that should be shown for "doc-77". Update the component so that: The UI…

Checking your access…