Skip to main content

State

Composable UI uses tRPC with React Query to provide functionality for fetching, mutating, caching, and synchronizing server state to all Components in the application.

The following hooks in React Query manages states in Composable UI:

  • useQuery: Retrieves data from an API endpoint and manages its caching, synchronization, and updating. You can pass following arguments to the hook:

    • A key that represents the unique identifier for the query.
    • A query function that returns the data you want to retrieve.
  • useMutation: Updates the server state as required.

You can import React Query hooks as in the following example:

import { useMutation } from '@tanstack/react-query'

You may also want to use React Query for other parts of your project whenever you want to query data from external APIs.