From 5e445a0011109954747b5759f150da29aa5d0ead Mon Sep 17 00:00:00 2001 From: Endi Date: Mon, 11 Nov 2019 19:56:22 +0700 Subject: [PATCH] fix(v2): useTOC hooks should not be called in each nested children (#1959) * fix(v2): useTOC hooks should not be called in each nested children * fragment * rename -> DocTOC --- .../src/theme/DocItem/index.js | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/docusaurus-theme-classic/src/theme/DocItem/index.js b/packages/docusaurus-theme-classic/src/theme/DocItem/index.js index 5678f93299..029613f2f9 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocItem/index.js +++ b/packages/docusaurus-theme-classic/src/theme/DocItem/index.js @@ -19,9 +19,18 @@ const LINK_CLASS_NAME = 'contents__link'; const ACTIVE_LINK_CLASS_NAME = 'contents__link--active'; const TOP_OFFSET = 100; -function Headings({headings, isChild}) { +function DocTOC({headings}) { useTOCHighlight(LINK_CLASS_NAME, ACTIVE_LINK_CLASS_NAME, TOP_OFFSET); + return ( +
+
+ +
+
+ ); +} +function Headings({headings, isChild}) { if (!headings.length) return null; return (