Skip to content

Commit 96a2142

Browse files
feat: SerializeFrom: remix-run/react-router#12417
1 parent 889be28 commit 96a2142

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

app/root.tsx

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
import {
2-
data,
3-
type LoaderFunctionArgs,
4-
type HeadersFunction,
5-
type LinksFunction,
6-
type MetaFunction,
7-
} from 'react-router';
8-
import {
9-
Form,
10-
Link,
11-
Links,
12-
Meta,
13-
Outlet,
14-
Scripts,
15-
ScrollRestoration,
16-
useLoaderData,
17-
useMatches,
18-
useSubmit,
19-
} from 'react-router';
201
import { withSentry } from '@sentry/remix'
212
import { useRef } from 'react'
3+
import {
4+
data,
5+
type LoaderFunctionArgs,
6+
type HeadersFunction,
7+
type LinksFunction,
8+
type MetaFunction,
9+
Form,
10+
Link,
11+
Links,
12+
Meta,
13+
Outlet,
14+
Scripts,
15+
ScrollRestoration,
16+
useLoaderData,
17+
useMatches,
18+
useSubmit,
19+
} from 'react-router'
2220
import { HoneypotProvider } from 'remix-utils/honeypot/react'
2321
import appleTouchIconAssetUrl from './assets/favicons/apple-touch-icon.png'
2422
import faviconAssetUrl from './assets/favicons/favicon.svg'

app/routes/settings+/profile.connections.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
data,
66
type LoaderFunctionArgs,
77
type ActionFunctionArgs,
8-
type SerializeFrom,
98
type HeadersFunction,
109
useFetcher,
1110
useLoaderData,
@@ -159,6 +158,8 @@ export default function Connections() {
159158
)
160159
}
161160

161+
type SerializeFrom<T> = ReturnType<typeof useLoaderData<T>>
162+
162163
function Connection({
163164
connection,
164165
canDelete,

app/routes/users+/$username_+/__note-editor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import {
99
} from '@conform-to/react'
1010
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
1111
import { type Note, type NoteImage } from '@prisma/client'
12-
import { type SerializeFrom } from 'react-router';
13-
import { Form, useActionData } from 'react-router';
1412
import { useState } from 'react'
13+
import { Form, useActionData, type useLoaderData } from 'react-router'
1514
import { z } from 'zod'
1615
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
1716
import { floatingToolbarClassName } from '#app/components/floating-toolbar.tsx'
@@ -44,6 +43,8 @@ const ImageFieldsetSchema = z.object({
4443

4544
export type ImageFieldset = z.infer<typeof ImageFieldsetSchema>
4645

46+
type SerializeFrom<T> = ReturnType<typeof useLoaderData<T>>
47+
4748
export const NoteEditorSchema = z.object({
4849
id: z.string().optional(),
4950
title: z.string().min(titleMinLength).max(titleMaxLength),

app/utils/user.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { type SerializeFrom, useRouteLoaderData } from 'react-router'
1+
import { useRouteLoaderData } from 'react-router'
22
import { type loader as rootLoader } from '#app/root.tsx'
33

4-
function isUser(user: any): user is SerializeFrom<typeof rootLoader>['user'] {
4+
function isUser(
5+
user: any,
6+
): user is Awaited<ReturnType<typeof rootLoader>>['data']['user'] {
57
return user && typeof user === 'object' && typeof user.id === 'string'
68
}
79

0 commit comments

Comments
 (0)