-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: lazy load katex and inline katex style
Signed-off-by: Innei <tukon479@gmail.com>
- Loading branch information
Showing
5 changed files
with
39 additions
and
30 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
apps/renderer/src/components/common/MemoedDangerousHTMLStyle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { FC } from "react" | ||
import { memo, useMemo } from "react" | ||
|
||
export const MemoedDangerousHTMLStyle: FC< | ||
{ | ||
children: string | ||
} & React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> & | ||
Record<string, unknown> | ||
> = memo(({ children, ...rest }) => ( | ||
<style | ||
{...rest} | ||
dangerouslySetInnerHTML={useMemo( | ||
() => ({ | ||
__html: children, | ||
}), | ||
[children], | ||
)} | ||
/> | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { lazy, Suspense } from "react" | ||
|
||
import type { KateX } from "./index" | ||
|
||
const LazyKateX_ = lazy(() => import("./index").then((mod) => ({ default: mod.KateX }))) | ||
export const LazyKateX: typeof KateX = (props) => { | ||
return ( | ||
<Suspense> | ||
<LazyKateX_ {...props} /> | ||
</Suspense> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters