Async State

React Native 7 min min read Updated: Jul 26, 2026 Intermediate
Async State
Intermediate Topic 12 of 20

Async State

Async state refers to data that comes from asynchronous sources, such as API calls, and requires tracking additional states like loading, success, and error, beyond just the data itself.

The Three Common Async States

  • Loading – The request is currently in progress.
  • Success – The request completed successfully with data returned.
  • Error – The request failed and an error message should be displayed.

Managing Async State Manually

javascript function useUsers() { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { fetch('https://api.example.com/users') .then((res) => res.json()) .then(setData) .catch(setError) .finally(() => setLoading(false)); }, []); return { data, loading, error }; }

Managing Async State with Redux Toolkit Query

RTK Query, part of Redux Toolkit, automatically manages loading, caching, and error states for API requests, significantly reducing manual async state management code.

javascript const { data, isLoading, error } = useGetUsersQuery();

Using React Query (TanStack Query)

React Query is a popular library specifically designed for managing async server state, including automatic caching, background refetching, and retry logic.

javascript import { useQuery } from '@tanstack/react-query'; const { data, isLoading, error } = useQuery({ queryKey: ['users'], queryFn: fetchUsers, });

Server State vs Client State

It is important to distinguish between server state, which comes from and is synchronized with a backend, and client state, which is purely local application data, since each benefits from different management strategies.

Conclusion

Properly managing async state, whether manually or with tools like RTK Query or React Query, ensures your React Native application handles loading, success, and error scenarios gracefully and predictably.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators