Skip to main content

react-query

A module that adds integration with the react-query library and is required for @tramvai/react-query

Link to complete React Query documentation - https://tramvai.dev/docs/features/data-fetching/react-query/

Installation

You need to install @tramvai/module-react-query

npx tramvai add @tramvai/module-react-query

And connect in the project

import { createApp } from '@tramvai/core';
import { ReactQueryModule } from '@tramvai/module-react-query';

createApp({
name: 'tincoin',
modules: [ReactQueryModule],
});

Explanation

The module adds an instance react-query QueryClient to the DI and allows specifying options for creating it.

The module also adds React wrappers for react-query to the application renderer, which allow using functions for working with query inside components.

Server

On the server, the module also additionally performs dehydration of the data preloaded on the server in order to transfer them to the client

Client

The browser additionally performs rehydration of the data preloaded on the server

API

The module basically provides the necessary things in DI for the library @tramvai/react-query and itself may be needed only if there is a need to change the settings for QueryClient or use QueryClient directly (but better not to use directly)

Exported tokens

link