Skip to content

Commit

Permalink
docs: added an example of conditional rendering for the Tabs component (
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang authored Dec 11, 2023
1 parent 5d76422 commit dbfc232
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/Tabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,60 @@ notes: |
</Tabs>
```

## Conditional rendering

```jsx live
() => {
const librariesEnabled = true;
const visibleTabs = useMemo(() => {
const tabs = [];

tabs.push(
<Tab
key="courses"
eventKey="courses"
title="Courses"
>
Hello I am the courses panel.
</Tab>
);

tabs.push(
<Tab
key="programs"
eventKey="programs"
title="Programs"
>
Hello I am the programs panel.
</Tab>
);

if (librariesEnabled) {
tabs.push(
<Tab
key="libraries"
eventKey="libraries"
title="Libraries"
>
Hello I am the libraries panel.
</Tab>
);
}

return tabs;
}, [librariesEnabled]);

return (
<Tabs
id="tabs"
defaultActiveKey="courses"
>
{visibleTabs}
</Tabs>
);
}
```

***

## Tabs.Deprecated
Expand Down

0 comments on commit dbfc232

Please sign in to comment.