Skip to content

Commit b947f98

Browse files
authored
chore(react-email): Pre-render email templates on hover (#2187)
1 parent d6a1239 commit b947f98

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changeset/tidy-geese-cross.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-email": patch
3+
---
4+
5+
Pre-render email templates on hover

packages/react-email/src/components/sidebar/file-tree-directory-children.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as Collapsible from '@radix-ui/react-collapsible';
22
import { AnimatePresence, LayoutGroup, motion } from 'framer-motion';
33
import Link from 'next/link';
4-
import { useSearchParams } from 'next/navigation';
4+
import { useRouter, useSearchParams } from 'next/navigation';
55
import { cn } from '../../utils';
66
import type { EmailsDirectory } from '../../utils/get-emails-directory-metadata';
77
import { IconFile } from '../icons/icon-file';
@@ -14,6 +14,7 @@ export const FileTreeDirectoryChildren = (props: {
1414
isRoot?: boolean;
1515
}) => {
1616
const searchParams = useSearchParams();
17+
const router = useRouter();
1718

1819
return (
1920
<AnimatePresence initial={false}>
@@ -71,7 +72,11 @@ export const FileTreeDirectoryChildren = (props: {
7172
pathname: `/preview/${emailSlug}`,
7273
search: searchParams.toString(),
7374
}}
74-
prefetch
75+
onMouseOver={() => {
76+
router.prefetch(
77+
`/preview/${emailSlug}?${searchParams.toString()}`,
78+
);
79+
}}
7580
key={emailSlug}
7681
>
7782
<motion.span

0 commit comments

Comments
 (0)