Skip to content

Commit 775b5c8

Browse files
Add jsdom to external packages (#1315)
* refactor: replace Children.toArray with Array.from for loading components Add jsdom to external packages * fix: update import path in next-env.d.ts and standardize quotes in next.config.js * fix: streamline loading component rendering in Articles, Notifications, and SavedPosts pages
1 parent 672bd65 commit 775b5c8

File tree

7 files changed

+15
-31
lines changed

7 files changed

+15
-31
lines changed

app/(app)/articles/_client.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { Children, Fragment, useEffect } from "react";
3+
import { Fragment, useEffect } from "react";
44
import { TagIcon } from "@heroicons/react/20/solid";
55
import ArticlePreview from "@/components/ArticlePreview/ArticlePreview";
66
import ArticleLoading from "@/components/ArticlePreview/ArticleLoading";
@@ -105,11 +105,7 @@ const ArticlesPage = () => {
105105
</div>
106106
)}
107107
{status === "pending" &&
108-
Children.toArray(
109-
Array.from({ length: 7 }, () => {
110-
return <ArticleLoading />;
111-
}),
112-
)}
108+
Array.from({ length: 7 }, (_, i) => <ArticleLoading key={i} />)}
113109
{status === "success" &&
114110
data.pages.map((page) => {
115111
return (

app/(app)/notifications/_client.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { Children, Fragment, useEffect } from "react";
3+
import { Fragment, useEffect } from "react";
44
import { useInView } from "react-intersection-observer";
55
import { CheckCircleIcon } from "@heroicons/react/20/solid";
66
import { Temporal } from "@js-temporal/polyfill";
@@ -91,11 +91,7 @@ const Notifications = () => {
9191
<div>Something went wrong... Please refresh your page.</div>
9292
)}
9393
{status === "pending" &&
94-
Children.toArray(
95-
Array.from({ length: 7 }, () => {
96-
return <Placeholder />;
97-
}),
98-
)}
94+
Array.from({ length: 7 }, (_, i) => <Placeholder key={i} />)}
9995
{status !== "pending" && noNotifications && (
10096
<p className="text-lg font-semibold text-neutral-900 dark:text-neutral-50">
10197
No new notifications. ✅{" "}

app/(app)/saved/_client.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use client";
22

3-
import { Children } from "react";
43
import ArticlePreview from "@/components/ArticlePreview/ArticlePreview";
54
import { api } from "@/server/trpc/react";
65
import PageHeading from "@/components/PageHeading/PageHeading";
@@ -33,11 +32,7 @@ const SavedPosts = () => {
3332
<PageHeading>Saved items</PageHeading>
3433
<div>
3534
{bookmarkStatus === "pending" &&
36-
Children.toArray(
37-
Array.from({ length: 7 }, () => {
38-
return <ArticleLoading />;
39-
}),
40-
)}
35+
Array.from({ length: 7 }, (_, i) => <ArticleLoading key={i} />)}
4136
{bookmarkStatus === "error" && (
4237
<p className="py-4 font-medium">
4338
Something went wrong fetching your saved posts... Refresh the page.

components/SideBar/SideBarSavedPosts.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22
import { api } from "@/server/trpc/react";
3-
import React, { Children } from "react";
3+
import React from "react";
44

55
import SideBarSavedArticlePreview from "./SideBarSavedArticlePreview";
66
import Link from "next/link";
@@ -22,11 +22,9 @@ export default React.memo(function SideBarSavedPosts() {
2222
</h3>
2323
<div className="w-full">
2424
{bookmarkStatus === "pending" &&
25-
Children.toArray(
26-
Array.from({ length: howManySavedToShow }, () => {
27-
return <LoadingSkeleton />;
28-
}),
29-
)}
25+
Array.from({ length: howManySavedToShow }, (_, i) => (
26+
<LoadingSkeleton key={i} />
27+
))}
3028
{bookmarkStatus === "error" && (
3129
<p className="py-4 font-medium">
3230
Something went wrong fetching your saved posts... Refresh the page.

components/TrendingPosts/TrendingPostsLoading.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import { Children } from "react";
21
import ArticleLoading from "@/components/ArticlePreview/ArticleLoading";
32

43
function LoadingTrendingPosts() {
54
return (
65
<div>
7-
{Children.toArray(
8-
Array.from({ length: 5 }, () => {
9-
return <ArticleLoading />;
10-
}),
11-
)}
6+
{Array.from({ length: 5 }, (_, i) => (
7+
<ArticleLoading key={i} />
8+
))}
129
</div>
1310
);
1411
}

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/types/routes.d.ts";
3+
import "./.next/dev/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

next.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const REMOTE_PATTERNS = [
2020
}));
2121

2222
const config = {
23+
// Exclude jsdom and isomorphic-dompurify from bundling to fix ESM/CJS compatibility
24+
serverExternalPackages: ["jsdom", "isomorphic-dompurify"],
2325
// Turbopack configuration for SVGR (replaces webpack config)
2426
turbopack: {
2527
rules: {

0 commit comments

Comments
 (0)