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
- You are using the latest version of React Router (v7).
7
+
- Always include the suffix `Page` when naming the default export of a route.
7
8
- The primary export in a routes file should specify `loaderData` like `export default function RouteNamePage({ loaderData }: Route.ComponentProps)`. `loaderData` is the return value from `clientLoader`.
8
9
- Use `href("/products/:id", { id: "abc123" })` to generate a url path for a route managed by the application.
9
10
- Look at [routes.ts](mdc:web/app/routes.ts) to determine what routes and path parameters exist.
@@ -43,7 +44,7 @@ export async function clientLoader(loaderArgs: Route.ClientLoaderArgs) {
43
44
}
44
45
```
45
46
46
-
### How to use clientLoader
47
+
### How to Use `clientLoader`
47
48
48
49
-`export async function clientLoader(loaderArgs: Route.ClientLoaderArgs) {`
49
50
- Load any server data required for page load here, not in the component function.
@@ -53,10 +54,38 @@ export async function clientLoader(loaderArgs: Route.ClientLoaderArgs) {
53
54
-`loaderArgs` and all sub-objects are all fully typed
54
55
-`loaderArgs.params.id` to get URL parameters
55
56
56
-
### Using API Data
57
+
### Loading Backend Data
57
58
58
59
-`~/configuration/client` re-exports all types and functions from `client/*`. Import from `~/configuration/client` instead of anything you find in the `client/` folder/package.
59
60
- For each API endpoint, there's a fully typed async function that can be used to call it. Never attempt to call an API endpoint directly.
61
+
- Do not generate types for API parameters or responses. Reference the autogenerated types that are re-exported in `~/configuration/client`
62
+
- For instance, the `getSignedUrl` function in [web/client/sdk.gen.ts] has a `SignedUrlResponse` type in [web/client/types.gen.ts]
63
+
- This same type is used in the function signature, i.e. `type SignedUrlResponse = Awaited<ReturnType<typeof getSignedUrl>>["data"]`
64
+
60
65
- When using an import from `~/configuration/client`:
0 commit comments