---
name: configure-expo-data-loading
description: Loads data in an Expo project with expo/fetch, four screen states, and an Expo Router loader. Use when the user wants a network request, a loading state, or useLoaderData.
license: MIT
metadata:
  category: apps
  tags: "expo"
  author: johnny-bravo
  version: "1.0"
  updated: "2026-11-09"
  status: published
  aliases: "expo-data-fetching, expo/fetch, useLoaderData, React Query"
  source_url: "https://github.com/expo/skills/tree/a9e5bd3fa00b4e61f632e43f85da73aee1942582/plugins/expo/skills/expo-data-fetching"
  source_license: MIT
  copyright: "Copyright (c) 2025-present 650 Industries, Inc. (aka Expo)"
  original_author: "Expo / 650 Industries (expo/skills, expo-data-fetching)"
  modified: "Adapted by TheSkillVault: rewritten as a short data-loading pass (expo/fetch, four states, loader, cached rows); dropped the client catalogue and auth recipes. Independent how-to, not official Expo documentation. No request was sent for this library."
  imported_on: "2026-11-09"
---

# Configure Expo data loading

A screen that loads data needs four states: loading, failure, empty, and content. Empty means the request finished with nothing to show. It is not the same as still waiting.

## When to use
- An Expo screen calls a network endpoint.
- The person sees a blank list when the request fails.
- Expo Router should load data with useLoaderData.

## When not to use
- The need is motion or a gesture. That is a separate skill.
- The need is an over-the-air bundle. That is a separate skill.
- The product is a website form. That is a separate skill.

## Steps
1. Prefer `expo/fetch` for the request. Do not add a second HTTP client for a simple call.
2. Draw loading, failure, empty, and content. A first load uses the loading state. A later refresh keeps the cached rows and shows a small failure if the refresh does not succeed.
3. Empty is a finished result with zero rows. Say why it is empty and offer the next action. Do not treat a missing response as empty.
4. While a save is in flight, block a second submit. On failure, keep the draft. Clear it only after success.
5. For an Expo Router screen that can load ahead of render, use useLoaderData. Wait until saved session state has loaded, then choose the first screen.
6. Read the four states through, then write the failure path so a bad response does not wipe cached rows. Do not paste an API key into a sample. This library did not send a request.

## Gotchas
- Do not include passwords, tokens, or private payloads in sample calls.
- A disabled or paused query can have no rows without being in the loading state. Show that case on its own.
- Environment URLs belong in the project config, not in a pasted sample.
- This is an independent how-to adapted from an Expo skill. It is not official Expo documentation, and no request was sent for this library.

## Portability
If you use TanStack Query or SWR, the same four states still hold. If you use a bare fetch outside Expo, keep expo/fetch only when the project is Expo. If you use a website stack, this skill does not cover it.

## Done when
- The screen has loading, failure, empty, and content.
- A failed refresh keeps cached rows.
- useLoaderData is used only where the router can load ahead of render.

## Example prompt
"This Expo list goes blank when the request fails. Keep the cached rows, and use expo/fetch with a real empty state."

---
Adapted from "expo-data-fetching" by 650 Industries, Inc. (aka Expo) (MIT, Copyright (c) 2025-present 650 Industries, Inc. (aka Expo)). See LICENSE.txt.
