From 571a991dd46544e71cfc41e7fdaef57a680f1bb0 Mon Sep 17 00:00:00 2001 From: Innei Date: Wed, 30 Apr 2025 22:11:16 +0800 Subject: [PATCH] fix(ssr): load i18n before renderer - Changed the initialization function to be asynchronous, ensuring all necessary setups are completed before rendering. - Modified the rendering logic in the Item component to return the memoized content directly. - Cleaned up the NormalListItem component by removing unnecessary wrapper elements and updating class names for better styling consistency. Signed-off-by: Innei --- apps/ssr/client/components/items/index.tsx | 26 ++++++++----------- apps/ssr/client/components/items/normal.tsx | 8 +++--- apps/ssr/client/index.tsx | 16 ++++++------ apps/ssr/client/initialize/index.ts | 7 +++-- .../src/ui/effect/MagneticHoverEffect.tsx | 4 +-- 5 files changed, 27 insertions(+), 34 deletions(-) diff --git a/apps/ssr/client/components/items/index.tsx b/apps/ssr/client/components/items/index.tsx index 539bf971c..6aa52d241 100644 --- a/apps/ssr/client/components/items/index.tsx +++ b/apps/ssr/client/components/items/index.tsx @@ -27,7 +27,7 @@ export const Item = ({ feed?: Feed view: FeedViewType }) => { - const renderContent = useMemo(() => { + return useMemo(() => { switch (true) { case viewsRenderType.Normal.includes(view): { return @@ -40,8 +40,6 @@ export const Item = ({ } } }, [entries, feed, view]) - - return
{renderContent}
} const NormalList: FC<{ @@ -53,18 +51,16 @@ const NormalList: FC<{ <> {entries?.map((entry) => ( -
- -
+
))} diff --git a/apps/ssr/client/components/items/normal.tsx b/apps/ssr/client/components/items/normal.tsx index 33144cc85..3991e6c41 100644 --- a/apps/ssr/client/components/items/normal.tsx +++ b/apps/ssr/client/components/items/normal.tsx @@ -29,7 +29,7 @@ function NormalListItemImpl({
@@ -41,7 +41,7 @@ function NormalListItemImpl({
{withDetails && (
-
+
{entry.entries.description}
diff --git a/apps/ssr/client/index.tsx b/apps/ssr/client/index.tsx index f47f4aadc..fa7875cbd 100644 --- a/apps/ssr/client/index.tsx +++ b/apps/ssr/client/index.tsx @@ -11,11 +11,11 @@ import { initialize } from "./initialize" import { router } from "./router" const $container = document.querySelector("#root") as HTMLElement -initialize() - -ReactDOM.createRoot($container).render( - - - - , -) +initialize().finally(() => { + ReactDOM.createRoot($container).render( + + + + , + ) +}) diff --git a/apps/ssr/client/initialize/index.ts b/apps/ssr/client/initialize/index.ts index 9c012df2d..397ca9655 100644 --- a/apps/ssr/client/initialize/index.ts +++ b/apps/ssr/client/initialize/index.ts @@ -4,9 +4,8 @@ import { initializeDayjs } from "@follow/components/dayjs" import { initAnalytics } from "./analytics" import { initSentry } from "./sentry" -export const initialize = () => { - initializeDayjs() - initI18n() +export const initialize = async () => { initAnalytics() - initSentry() + initializeDayjs() + await Promise.all([initI18n(), initSentry()]) } diff --git a/packages/internal/components/src/ui/effect/MagneticHoverEffect.tsx b/packages/internal/components/src/ui/effect/MagneticHoverEffect.tsx index c16107cb6..1234b77e3 100644 --- a/packages/internal/components/src/ui/effect/MagneticHoverEffect.tsx +++ b/packages/internal/components/src/ui/effect/MagneticHoverEffect.tsx @@ -59,8 +59,8 @@ const MagneticHoverEffect = ( {...rest} className={cn( "relative", - "inline-block transition-all duration-200 ease-out", - "hover:bg-material-ultra-thick", + "inline-block transition-transform duration-200 ease-out will-change-transform", + "hover:before:bg-material-ultra-thick", "before:backdrop-blur-background before:absolute before:-inset-x-2 before:inset-y-0 before:z-[-1] before:scale-0 before:rounded-xl before:opacity-0 before:transition-all before:duration-200 before:[transform-origin:var(--origin-x)_var(--origin-y)] hover:before:scale-100 hover:before:opacity-100", rest.className, )}