-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
React__tabs-with-router #1003
base: master
Are you sure you want to change the base?
React__tabs-with-router #1003
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.
Good job 👍
Let's improve your code
src/components/TabsPage/TabsPage.tsx
Outdated
</div> | ||
|
||
<div className="block" data-cy="TabContent"> | ||
{tabs.find(t => t.id === selectId) |
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.
You're using 'tabs.find' to check if the tab exists and then 'tabs.filter' to extract the tab. This can be optimized by just using 'tabs.find' and storing the result in a variable, which improves performance by reducing the number of iterations over the 'tabs' array.
src/components/TabsPage/TabsPage.tsx
Outdated
{tabs.map(tab => ( | ||
<li |
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.
You can use a destructuring for tab
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.
Well done 🔥
DEMO - https://Soi4An.github.io/react_tabs-with-router/