-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 #1095
base: master
Are you sure you want to change the base?
solution #1095
Conversation
svitlanak31
commented
Oct 8, 2024
- DEMO LINK
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.
Good job 👍
Let's make your code better
src/App.jsx
Outdated
return ( | ||
<div className="section"> | ||
<h1 className="title"> | ||
Selected tab is {tabs.find(tab => tab.id === activeTabId).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.
Move this logic to the helper variable and use it here
src/App.jsx
Outdated
<h1 className="title"> | ||
Selected tab is {tabs.find(tab => tab.id === activeTabId).title} | ||
</h1> | ||
<Tabs tabs={tabs} activeTabId={activeTabId} onTabSelected={setActiveTabId} /> |
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.
<Tabs tabs={tabs} activeTabId={activeTabId} onTabSelected={setActiveTabId} /> | |
<Tabs | |
tabs={tabs} | |
activeTabId={activeTabId} | |
onTabSelected={setActiveTabId} | |
/> |
src/components/Tabs/Tabs.jsx
Outdated
{tabs.map((tab) => ( | ||
<li | ||
key={tab.id} | ||
className={tab.id === currentTabId ? '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 the classnames library for add classes with condition
src/components/Tabs/Tabs.jsx
Outdated
data-cy="TabLink" | ||
onClick={() => handleTabClick(tab.id)} | ||
> | ||
{tab.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.
Use destructuring for tab
src/components/Tabs/Tabs.jsx
Outdated
</ul> | ||
</div> | ||
<div className="block" data-cy="TabContent"> | ||
{tabs.find((tab) => tab.id === currentTabId)?.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.
Move this logic from jsx to the helper variable and use it here
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.
lgtm 🚀