|
1 | | -import beautify from "beautify" |
2 | | -import { useEffect, useState } from "react" |
3 | | -import ReactDiffViewer, { DiffMethod } from "react-diff-viewer-continued" |
4 | 1 | import { Icon } from "../components/icon/Icon.js" |
5 | 2 | import { useHtmlErrors } from "../context/useRDTContext.js" |
6 | 3 | import { useStyles } from "../styles/use-styles.js" |
7 | 4 | import { openSource } from "../utils/open-source.js" |
8 | | -// @ts-expect-error |
9 | | -const DiffViewer: typeof ReactDiffViewer.default = ReactDiffViewer.default |
10 | | - ? // @ts-expect-error |
11 | | - // biome-ignore lint/suspicious/noExplicitAny: we don't care about the type |
12 | | - (ReactDiffViewer.default as any) |
13 | | - : // biome-ignore lint/suspicious/noExplicitAny: we don't care about the type |
14 | | - (ReactDiffViewer as any) |
15 | 5 |
|
16 | 6 | const ErrorsTab = () => { |
17 | 7 | const { styles } = useStyles() |
18 | 8 | const { htmlErrors } = useHtmlErrors() |
19 | | - const [SSRHtml, setSSRHtml] = useState("") |
20 | | - const [CSRHtml, setCSRHtml] = useState("") |
21 | | - const [hasHydrationMismatch, setHasHydrationMismatch] = useState(false) |
22 | | - |
23 | | - useEffect(() => { |
24 | | - if (typeof window === "undefined") return |
25 | | - if (!window.HYDRATION_OVERLAY) { |
26 | | - return |
27 | | - } |
28 | | - const ssrHtml = window.HYDRATION_OVERLAY?.SSR_HTML |
29 | | - const newCSRHtml = window.HYDRATION_OVERLAY?.CSR_HTML |
30 | | - |
31 | | - if (!ssrHtml || !newCSRHtml) return |
32 | | - |
33 | | - const newSSR = beautify(ssrHtml, { format: "html" }) |
34 | | - const newCSR = beautify(newCSRHtml, { format: "html" }) |
35 | | - setSSRHtml(newSSR) |
36 | | - setCSRHtml(newCSR) |
37 | | - setHasHydrationMismatch(window.HYDRATION_OVERLAY?.ERROR ?? false) |
38 | | - }, []) |
39 | 9 |
|
40 | 10 | return ( |
41 | 11 | <div className={styles.errorsTab.container}> |
@@ -84,78 +54,6 @@ const ErrorsTab = () => { |
84 | 54 | </div> |
85 | 55 | ) |
86 | 56 | })} |
87 | | - {hasHydrationMismatch && ( |
88 | | - <div className={styles.errorsTab.hydrationContainer}> |
89 | | - <h1 className={styles.errorsTab.hydrationTitle}>Hydration mismatch comparison</h1> |
90 | | - <hr className={styles.errorsTab.hydrationDivider} /> |
91 | | - <DiffViewer |
92 | | - oldValue={SSRHtml} |
93 | | - newValue={CSRHtml} |
94 | | - leftTitle={"Server-Side Render"} |
95 | | - rightTitle={"Client-Side Render"} |
96 | | - compareMethod={DiffMethod.WORDS} |
97 | | - styles={{ |
98 | | - titleBlock: { |
99 | | - textAlign: "center", |
100 | | - }, |
101 | | - variables: { |
102 | | - light: { |
103 | | - diffViewerBackground: "#212121", |
104 | | - diffViewerColor: "#FFF", |
105 | | - addedBackground: "#044B53", |
106 | | - addedColor: "white", |
107 | | - removedBackground: "#632F34", |
108 | | - removedColor: "white", |
109 | | - wordAddedBackground: "#055d67", |
110 | | - wordRemovedBackground: "#7d383f", |
111 | | - addedGutterBackground: "#034148", |
112 | | - removedGutterBackground: "#632b30", |
113 | | - gutterBackground: "#1F2937", |
114 | | - highlightBackground: "#212121", |
115 | | - highlightGutterBackground: "#212121", |
116 | | - codeFoldGutterBackground: "#1F2937", |
117 | | - codeFoldBackground: "#1F2937", |
118 | | - emptyLineBackground: "#363946", |
119 | | - gutterColor: "#white", |
120 | | - addedGutterColor: "#8c8c8c", |
121 | | - removedGutterColor: "#8c8c8c", |
122 | | - codeFoldContentColor: "white", |
123 | | - diffViewerTitleBackground: "#212121", |
124 | | - diffViewerTitleColor: "white", |
125 | | - diffViewerTitleBorderColor: "#353846", |
126 | | - }, |
127 | | - dark: { |
128 | | - diffViewerBackground: "#212121", |
129 | | - diffViewerColor: "#FFF", |
130 | | - addedBackground: "#044B53", |
131 | | - addedColor: "white", |
132 | | - removedBackground: "#632F34", |
133 | | - removedColor: "white", |
134 | | - wordAddedBackground: "#055d67", |
135 | | - wordRemovedBackground: "#7d383f", |
136 | | - addedGutterBackground: "#034148", |
137 | | - removedGutterBackground: "#632b30", |
138 | | - gutterBackground: "#1F2937", |
139 | | - highlightBackground: "#212121", |
140 | | - highlightGutterBackground: "#212121", |
141 | | - codeFoldGutterBackground: "#1F2937", |
142 | | - codeFoldBackground: "#1F2937", |
143 | | - emptyLineBackground: "#363946", |
144 | | - gutterColor: "#white", |
145 | | - addedGutterColor: "#8c8c8c", |
146 | | - removedGutterColor: "#8c8c8c", |
147 | | - codeFoldContentColor: "white", |
148 | | - diffViewerTitleBackground: "#212121", |
149 | | - diffViewerTitleColor: "white", |
150 | | - diffViewerTitleBorderColor: "#353846", |
151 | | - }, |
152 | | - }, |
153 | | - }} |
154 | | - extraLinesSurroundingDiff={2} |
155 | | - useDarkTheme={true} |
156 | | - /> |
157 | | - </div> |
158 | | - )} |
159 | 57 | </div> |
160 | 58 | ) |
161 | 59 | } |
|
0 commit comments