You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have used the React-specific version of `createApi`, the generated `Api` slice structure will also contain a set of React hooks. The primary endpoint hooks are available as `api.endpoints[endpointName].useQuery` or `api.endpoints[endpointName].useMutation`, matching how you defined that endpoint.
22
+
If you have used the React-specific version of `createApi`, the generated `api` slice structure will also contain a set of React hooks. The primary endpoint hooks are available as `api.endpoints[endpointName].useQuery` or `api.endpoints[endpointName].useMutation`, matching how you defined that endpoint.
23
23
24
-
The same hooks are also added to the `Api` object itself, and given auto-generated names based on the endpoint name and query/mutation type.
24
+
### Generated Hook Names
25
+
26
+
The same hooks are also added to the `api` object itself, and given auto-generated names based on the endpoint name and query/mutation type.
25
27
26
28
For example, if you had endpoints for `getPosts` and `updatePost`, these options would be available:
The general format is `use(Endpointname)(Query|Mutation)` - `use` is prefixed, the first letter of your endpoint name is capitalized, then `Query` or `Mutation` is appended depending on the type.
39
41
40
-
RTK Query provides additional hooks for more advanced use-cases, although not all are generated directly on the `Api` object as well. The full list of hooks generated in the React-specific version of `createApi` is as follows:
42
+
### Available Hooks
43
+
44
+
RTK Query provides additional hooks for more advanced use-cases, although not all are generated directly on the `api` object as well.
45
+
46
+
Most of the hooks are generated on a per-endpoint basis.
41
47
42
-
-[`useQuery`](#usequery) (endpoint-specific, also generated on the `Api` object)
43
-
-[`useMutation`](#usemutation) (endpoint-specific, also generated on the `Api` object)
0 commit comments