From 9f44833a68c2af09768619b4a1699879146242ad Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 15 Dec 2022 13:50:24 +0800 Subject: [PATCH] hook-checks --- themes/next/components/Toc.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/themes/next/components/Toc.js b/themes/next/components/Toc.js index 5dbbad5f..6d98ee4a 100644 --- a/themes/next/components/Toc.js +++ b/themes/next/components/Toc.js @@ -11,10 +11,6 @@ import Progress from './Progress' * @constructor */ const Toc = ({ toc }) => { - // 无目录就直接返回空 - if (!toc || toc.length < 1) { - return <> - } // 监听滚动事件 React.useEffect(() => { window.addEventListener('scroll', actionSectionScrollSpy) @@ -58,6 +54,11 @@ const Toc = ({ toc }) => { tRef?.current?.scrollTo({ top: 28 * index, behavior: 'smooth' }) }, throttleMs)) + // 无目录就直接返回空 + if (!toc || toc.length < 1) { + return <> + } + return