Skip to content

Commit ea12adc

Browse files
authored
Merge pull request #1066 from Shrugsy/docs/add-rtk-query-getting-started-page
2 parents 77b576c + 5c5a2f8 commit ea12adc

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

docs/api/rtk-query/fetchBaseQuery.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ hide_table_of_contents: false
88

99
# `fetchBaseQuery`
1010

11-
This is a very small wrapper around `fetch` that aims to simplify requests. It is not a full-blown replacement for `axios`, `superagent`, or any other more heavy-weight library, but it will cover the large majority of your needs.
11+
This is a very small wrapper around [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) that aims to simplify requests. It is not a full-blown replacement for `axios`, `superagent`, or any other more heavy-weight library, but it will cover the large majority of your needs.
1212

1313
It takes all standard options from fetch's [`RequestInit`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch) interface, as well as `baseUrl`, a `prepareHeaders` function, and an optional `fetch` function.
1414

docs/introduction/getting-started.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The **Redux Toolkit** package is intended to be the standard way to write [Redux
1717

1818
We can't solve every use case, but in the spirit of [`create-react-app`](https://github.com/facebook/create-react-app) and [`apollo-boost`](https://dev-blog.apollodata.com/zero-config-graphql-state-management-27b1f1b3c2c3), we can try to provide some tools that abstract over the setup process and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.
1919

20-
Redux Toolkit also includes a powerful data fetching and caching capability that we've dubbed "RTK Query". It's included in the package as a separate set of entry points. It's optional, but can eliminate the need to hand-write data fetching logic yourself.
20+
Redux Toolkit also includes a powerful data fetching and caching capability that we've dubbed ["RTK Query"](#rtk-query). It's included in the package as a separate set of entry points. It's optional, but can eliminate the need to hand-write data fetching logic yourself.
2121

2222
**These tools should be beneficial to all Redux users**. Whether you're a brand new Redux user setting up your
2323
first project, or an experienced user who wants to simplify an existing application, **Redux Toolkit** can help
@@ -66,6 +66,31 @@ Redux Toolkit includes these APIs:
6666
- [`createEntityAdapter`](../api/createEntityAdapter.mdx): generates a set of reusable reducers and selectors to manage normalized data in the store
6767
- The [`createSelector` utility](../api/createSelector.mdx) from the [Reselect](https://github.com/reduxjs/reselect) library, re-exported for ease of use.
6868

69+
## RTK Query
70+
71+
**RTK Query** is provided as an optional addon within the `@reduxjs/toolkit` package. It is purpose-built to solve the use case of data fetching and caching, supplying a compact, but powerful toolset to define an API interface layer for your app. It is intended to simplify common cases for loading data in a web application, eliminating the need to hand-write data fetching & caching logic yourself.
72+
73+
RTK Query is built on top of the Redux Toolkit core for it's implementation, using [Redux](https://redux.js.org/) internally for it's architecture. Although knowledge of Redux and RTK are not required to use RTK Query, you should explore all of the additional global store management capabilities they provide, as well as installing the [Redux DevTools browser extension](https://github.com/reduxjs/redux-devtools), which works flawlessly with RTK Query to traverse and replay a timeline of your request & cache behavior.
74+
75+
RTK Query is included within the installation of the core Redux Toolkit package. It is available via either of the two entry points below:
76+
77+
```ts no-transpile
78+
import { createApi } from '@reduxjs/toolkit/query'
79+
80+
/* React-specific entry point that automatically generates
81+
hooks corresponding to the defined endpoints */
82+
import { createApi } from '@reduxjs/toolkit/query/react'
83+
```
84+
85+
### What's included
86+
87+
RTK Query includes these APIs:
88+
89+
- [`createApi()`](../api/rtk-query/createApi.mdx): The core of RTK Query's functionality. It allows you to define a set of endpoints describe how to retrieve data from a series of endpoints, including configuration of how to fetch and transform that data.
90+
- [`fetchBaseQuery()`](../api/rtk-query/fetchBaseQuery.mdx): A small wrapper around [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) that aims to simply requests. Intended as the recommended `baseQuery` to be used in `createApi` for the majority of users.
91+
- [`<ApiProvider />`](../api/rtk-query/ApiProvider.mdx): Can be used as a `Provider` if you **do not already have a Redux store**.
92+
- [`setupListeners()`](../api/rtk-query/setupListeners.mdx): A utility used to enable `refetchOnMount` and `refetchOnReconnect` behaviors.
93+
6994
## Help and Discussion
7095

7196
The **[#redux channel](https://discord.gg/0ZcbPKXt5bZ6au5t)** of the **[Reactiflux Discord community](http://www.reactiflux.com)** is our official resource for all questions related to learning and using Redux. Reactiflux is a great place to hang out, ask questions, and learn - come join us!

0 commit comments

Comments
 (0)