Skip to content

Commit

Permalink
fix(v2): allows to create tabs with only one item (#1934)
Browse files Browse the repository at this point in the history
* fix(v2): allow to create tabs with only one item

It was not possible to have tabs containing only one tab item, so the code below crashed

```
<Tabs
    defaultValue="SomeFile.js"
    values={[
        { label: "SomeFile.js", value: "SomeFile.js" }
    ]}
>
<TabItem value="SomeFile.js">
    Tab content
</TabItem>
</Tabs>
```

* Update index.js
  • Loading branch information
Bohdan Shulha authored and yangshun committed Nov 4, 2019
1 parent 146a301 commit 9c34bb7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-classic/src/theme/Tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Tabs(props) {
))}
</ul>
<div className="margin-vert--md">
{children.filter(child => child.props.value === selectedValue)[0]}
{[...children].filter(child => child.props.value === selectedValue)[0]}
</div>
</div>
);
Expand Down

0 comments on commit 9c34bb7

Please sign in to comment.