-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution #1192
base: master
Are you sure you want to change the base?
solution #1192
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix your DEMO link
src/App.jsx
Outdated
</ul> | ||
</div> | ||
export const App = () => { | ||
const [activeTabId, setActiveTabId] = useState('tab-1'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [activeTabId, setActiveTabId] = useState('tab-1'); | |
const [activeTabId, setActiveTabId] = useState(tabs[0].id); |
src/App.jsx
Outdated
let selectedTitle = 'Selected tab is '; | ||
|
||
if (activeTab) { | ||
selectedTitle += activeTab.title; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is not needed
src/components/Tabs/Tabs.jsx
Outdated
<div className="tabs is-boxed"> | ||
<ul> | ||
{tabs.map(tab => { | ||
const className = tab.id === validTabId ? 'is-active' : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use classnames
for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/Tabs/Tabs.jsx
Outdated
const validTabId = tabs.some(tab => tab.id === activeTabId) | ||
? activeTabId | ||
: tabs[0].id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not really needed
const validTabId = tabs.some(tab => tab.id === activeTabId) | |
? activeTabId | |
: tabs[0].id; |
src/components/Tabs/Tabs.jsx
Outdated
})} | ||
</ul> | ||
<div className="block" data-cy="TabContent"> | ||
{tabs.find(tab => tab.id === validTabId)?.content} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create variable for {tabs.find(tab => tab.id === validTabId)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving it with only one minor comment!
{tabs.map(tab => ( | ||
<li | ||
key={tab.id} | ||
className={classNames({ 'is-active': tab.id === activeTabId })} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move into const and reuse tab.id === activeTabId
DEMO LINK