Implement the Tabs
component that renders several tabs and allows the user to switch between them.
Here is the working version
The App
should communicate with the Tabs
component using the following props:
tabs
- an array of tab objects to be rendered asTabs
;activeTabId
- theid
of the tab that should be active;onTabSelected
- a callback executed with theid
of a just selected tab when the user clicks on it.
The Tabs
component should be stateless (does not have an internal state, only props).
Follow the next requirements to pass the tests:
- Render tabs in a list (
<ul>
); - Each
<li>
should have adata-cy="Tab"
. - The
<li>
of an active tab should have theis-active
class. - If
activeTabId
does not match any object in thetabs
array, the first one should be active. - Add a link with
data-cy="TabLink"
and ahref
to#tab-id
inside every<li>
(see the markup). - The
Tabs
component should render the content of the active tab in the element withdata-cy="TabContent"
. - Call
onTabSelected
only when the user selects a non-active tab. - Use the title of the active tab in the
<h1>
of theApp
component in the following format:Selected tab is Tab 1
.
- Install the Prettier Extension and use these VSCode settings to enable format on save.
- Implement a solution following the React task guidelines.
- Open one more terminal and run tests with
npm test
to ensure your solution is correct. - Replace
<your_account>
with your Github username in the DEMO LINK and add it to the PR description.