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
Copy file name to clipboardExpand all lines: website/docs/codegen/openapi/create-api-client-function/index.mdx
+30-45Lines changed: 30 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,51 +148,30 @@ the necessary `requestFn`, `baseUrl` and `queryClient` for React Hooks.
148
148
```
149
149
</TabItem>
150
150
<TabItemvalue="multiple-api-versions"label={<spanstyle={{verticalAlign: 'middle'}}>Multiple API versions and <em>React <code>Context</code></em></span>}>
151
-
In this example, we create multiple API clients that manage two different API versions, each with its own `QueryClient`.
152
-
This approach mounts and unmounts `QueryClient` instances during the lifecycle of the application.
151
+
This example demonstrates how to use multiple API clients with React Context. With the `context:` option
152
+
in CLI, you can generate an API client that retrieves `queryClient`, `requestFn`, and `baseUrl` from
153
+
React Context at render time.
153
154
154
-
This setup is particularly useful when you need to work with different API versions simultaneously, or when you're in the process
155
-
of migrating from one API version to another.
155
+
:::tip React Compiler Compatibility
156
+
Creating the API client **outside of the component** with the `context:` option makes hooks static,
157
+
allowing React Compiler to optimize them. If you create the client inside `useMemo`, hooks become
158
+
dynamic and cannot be optimized by React Compiler.
the `createCustomClient()` function in the `create-custom-api.ts` file with no default services and only `setQueryData()` and `getQueryData()` callbacks
0 commit comments