From 3b9309fa87c3fc5ca73710dcd000fadf27ce7037 Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Tue, 5 Nov 2019 04:30:44 +0300 Subject: [PATCH] fix(v2): fix build caused when one tab item (#1938) * fix(v2): fix build caused when one tab item * Use React method --- CHANGELOG-2.x.md | 1 + packages/docusaurus-theme-classic/src/theme/Tabs/index.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-2.x.md b/CHANGELOG-2.x.md index 999e9334c482..a642982a4660 100644 --- a/CHANGELOG-2.x.md +++ b/CHANGELOG-2.x.md @@ -2,6 +2,7 @@ ## Unreleased +- **HOTFIX for 2.0.0-alpha.32** - Fix build compilation if exists only one code tab. - Add table of contents highlighting on scroll. ## 2.0.0-alpha.32 diff --git a/packages/docusaurus-theme-classic/src/theme/Tabs/index.js b/packages/docusaurus-theme-classic/src/theme/Tabs/index.js index a2b9d883fd97..7aae32d9f433 100644 --- a/packages/docusaurus-theme-classic/src/theme/Tabs/index.js +++ b/packages/docusaurus-theme-classic/src/theme/Tabs/index.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import React, {useState} from 'react'; +import React, {useState, Children} from 'react'; import classnames from 'classnames'; @@ -31,7 +31,11 @@ function Tabs(props) { ))}
- {[...children].filter(child => child.props.value === selectedValue)[0]} + { + Children.toArray(children).filter( + child => child.props.value === selectedValue, + )[0] + }
);