From ae91658636cd8abfcd66af6efc7970d77cfa07b3 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 7 Nov 2021 01:26:52 +0000 Subject: [PATCH] [Not for merge] Perf investigation --- beta/src/components/Layout/Sidebar/SidebarLink.tsx | 10 +++++----- beta/src/components/Layout/useTocHighlight.tsx | 1 + beta/src/components/MDX/Challenges/Navigation.tsx | 2 +- beta/src/components/MDX/CodeBlock/CodeBlock.tsx | 1 + beta/src/components/MDX/Sandpack/index.tsx | 1 + 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/beta/src/components/Layout/Sidebar/SidebarLink.tsx b/beta/src/components/Layout/Sidebar/SidebarLink.tsx index 93aa8e0d8ef..19bcfccde77 100644 --- a/beta/src/components/Layout/Sidebar/SidebarLink.tsx +++ b/beta/src/components/Layout/Sidebar/SidebarLink.tsx @@ -38,11 +38,11 @@ export function SidebarLink({ React.useEffect(() => { if (ref && ref.current && !!selected && !isMobile) { - scrollIntoView(ref.current, { - scrollMode: 'if-needed', - block: 'center', - inline: 'nearest', - }); + // scrollIntoView(ref.current, { + // scrollMode: 'if-needed', + // block: 'center', + // inline: 'nearest', + // }); } }, [ref, selected, isMobile]); diff --git a/beta/src/components/Layout/useTocHighlight.tsx b/beta/src/components/Layout/useTocHighlight.tsx index a8538381fdd..2b9e25fa3d3 100644 --- a/beta/src/components/Layout/useTocHighlight.tsx +++ b/beta/src/components/Layout/useTocHighlight.tsx @@ -28,6 +28,7 @@ export function useTocHighlight() { const timeoutRef = React.useRef(null); React.useEffect(() => { + return; function updateActiveLink() { const pageHeight = document.body.scrollHeight; const scrollPosition = window.scrollY + window.innerHeight; diff --git a/beta/src/components/MDX/Challenges/Navigation.tsx b/beta/src/components/MDX/Challenges/Navigation.tsx index b91b8e17464..8ec483b909a 100644 --- a/beta/src/components/MDX/Challenges/Navigation.tsx +++ b/beta/src/components/MDX/Challenges/Navigation.tsx @@ -76,7 +76,7 @@ export function Navigation({ }, [containerRef, challengesNavRef, scrollPos]); React.useEffect(() => { - handleResize(); + //handleResize(); window.addEventListener('resize', debounce(handleResize, 200)); return () => { window.removeEventListener('resize', handleResize); diff --git a/beta/src/components/MDX/CodeBlock/CodeBlock.tsx b/beta/src/components/MDX/CodeBlock/CodeBlock.tsx index a84680dd9ac..6eae47f3a1d 100644 --- a/beta/src/components/MDX/CodeBlock/CodeBlock.tsx +++ b/beta/src/components/MDX/CodeBlock/CodeBlock.tsx @@ -38,6 +38,7 @@ const CodeBlock = React.forwardRef( }, ref?: React.Ref ) => { + return
lol
const getDecoratedLineInfo = () => { if (!metastring) { return []; diff --git a/beta/src/components/MDX/Sandpack/index.tsx b/beta/src/components/MDX/Sandpack/index.tsx index 3cfa4ebd67a..7ca14fc908d 100644 --- a/beta/src/components/MDX/Sandpack/index.tsx +++ b/beta/src/components/MDX/Sandpack/index.tsx @@ -64,6 +64,7 @@ ul { `.trim(); function Sandpack(props: SandpackProps) { + return
lol
let {children, setup, autorun = true} = props; let [resetKey, setResetKey] = React.useState(0); let codeSnippets = React.Children.toArray(children) as React.ReactElement[];