Take a look around.
React Native / API flows

Connecting a React Native screen to an API: the states to agree on

By Lan T.6 min read

Agree on the request, the response and the visible result for success, loading, empty data, an expired session and failure. A mock response can help you review the interface; the real API still needs its own checks.

Diagram: user task, then api contract, then screen states, then recovery.
Agree on the task, the contract and the recovery path before calling the screen finished.Open the full diagram ↗

Start with the task, not the spinner

“Connect this screen to the API” leaves several decisions open. What happens after a tap? Can the person tap again? Will a failed request lose their input? Can the screen still show older data while it refreshes?

Use one complete action as the unit of work. For an event app, that might be opening an event, reading its current availability and asking to join. The API and the interface should agree on the possible outcomes.

Write down the contract before the UI guesswork

Record the endpoint or contract function, required input, authentication, response shape and error codes. Decide which system is authoritative for availability and membership state. A disabled button can explain a rule, but the server still has to enforce it.

LaClub uses shared definitions for requests and errors across its app and API. For your own feature, agree on the visible result of each response so design, implementation and review follow the same journey.

StateWhat the person seesWhat to check
LoadingA clear pending state; previous content where appropriateSlow response and repeated taps
SuccessThe returned result and a clear next actionDisplayed state agrees with the API
EmptyA useful explanation and a way forwardA valid response with no records
No longer availableAn explanation that the state changedServer rejects an outdated action
Expired sessionA route to sign in againProtected data/actions stay protected
FailureA readable message and an appropriate retryInput is preserved; duplicate effects are avoided

Treat repeated taps as part of the flow

Show that work is in progress and stop accidental repeated submissions while the request is pending. Do not rely on that UI alone to prevent duplicate business actions. The backend needs a rule for repeated requests where creating a second record would be harmful.

Also decide what happens if the person leaves the screen. A late response should not overwrite a newer selection or produce a confusing message on another page. The appropriate cancellation and retry behavior depends on the request and the data library you use.

Make failure recoverable

Separate a network failure from a valid response that says the action is not permitted or no longer available. A generic “try again” can make a permission problem look like a temporary outage.

For a failed write, a timeout does not always tell you whether the server completed the action. Agree how the app will check the current result before blindly trying the same business action again. This matters for bookings, payments and joining flows.

  • Keep useful input when a request fails.
  • Use messages the person can act on; keep private debugging details out of the UI.
  • Provide retry where it is safe and explain when the user must change something.
  • Check the final server state before presenting a successful result.

A small review matrix beats a vague “done”

Give the reviewer a build and a short list of actions they can repeat. Identify whether each response comes from a mock, local API or staging service. Controlled responses are helpful for inspecting the UI, while integration checks establish what the actual service does.

  • Review layout and keyboard behavior on the agreed native targets.
  • Exercise slow and failed responses deliberately, rather than waiting for them to happen.
  • Record what was checked and what could not be checked in the current environment.
  • Successful response changes the visible state
  • Pending request handles repeated taps
  • Empty or unavailable state has a next step
  • Expired session follows the agreed sign-in flow
  • Failed request preserves useful input
  • Retrying does not create an unintended duplicate
  • Final result is checked against the API

What a good-looking screen does not prove

A screenshot can show a layout and its sample content. It cannot prove permissions, API availability, concurrency or recovery after a real provider failure. Keep the screenshot and the acceptance record together, with a label on each.

Explore LaClub’s member and host screens for a concrete product example. Then use the questions in this note to agree on the states your own feature needs.

Further reading & related work

Product examples and references for the decisions in this note.

Have a similar piece of work?

Bring the screen, the API contract and the state that is getting stuck.

Tell me what you’re working on ↗

Keep reading