From dfff15f00cfbd3355efeb2a9501b4df5f405eb7a Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Mon, 4 Nov 2019 19:26:03 +0300 Subject: [PATCH 1/2] fix(v2): fix build caused when one tab item --- CHANGELOG-2.x.md | 6 ++++++ packages/docusaurus-theme-classic/src/theme/Tabs/index.js | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-2.x.md b/CHANGELOG-2.x.md index 5f2661f3b983..d292ccf4f1c1 100644 --- a/CHANGELOG-2.x.md +++ b/CHANGELOG-2.x.md @@ -2,6 +2,12 @@ ## Unreleased +## 2.0.0-alpha.33 + +**HOTFIX for 2.0.0-alpha.32**. + +- Fix build compilation if exists only one code tab. + ## 2.0.0-alpha.32 ### Features diff --git a/packages/docusaurus-theme-classic/src/theme/Tabs/index.js b/packages/docusaurus-theme-classic/src/theme/Tabs/index.js index a2b9d883fd97..f314b28a2b8e 100644 --- a/packages/docusaurus-theme-classic/src/theme/Tabs/index.js +++ b/packages/docusaurus-theme-classic/src/theme/Tabs/index.js @@ -31,7 +31,11 @@ function Tabs(props) { ))}
- {[...children].filter(child => child.props.value === selectedValue)[0]} + { + Array.from(children).filter( + child => child.props.value === selectedValue, + )[0] + }
); From a8aa333c8bd1ed2d1f7b010b30b1112073b9b19b Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Tue, 5 Nov 2019 04:19:39 +0300 Subject: [PATCH 2/2] Use React method --- packages/docusaurus-theme-classic/src/theme/Tabs/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-theme-classic/src/theme/Tabs/index.js b/packages/docusaurus-theme-classic/src/theme/Tabs/index.js index f314b28a2b8e..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'; @@ -32,7 +32,7 @@ function Tabs(props) {
{ - Array.from(children).filter( + Children.toArray(children).filter( child => child.props.value === selectedValue, )[0] }