Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Yevhen-Filimonov
Copy link

Copy link

@Moroz-Dmytro Moroz-Dmytro left a 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');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [activeTabId, setActiveTabId] = useState('tab-1');
const [activeTabId, setActiveTabId] = useState(tabs[0].id);

src/App.jsx Outdated
Comment on lines 22 to 26
let selectedTitle = 'Selected tab is ';

if (activeTab) {
selectedTitle += activeTab.title;
}

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

<div className="tabs is-boxed">
<ul>
{tabs.map(tab => {
const className = tab.id === validTabId ? 'is-active' : '';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use classnames for this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 4 to 6
const validTabId = tabs.some(tab => tab.id === activeTabId)
? activeTabId
: tabs[0].id;

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

Suggested change
const validTabId = tabs.some(tab => tab.id === activeTabId)
? activeTabId
: tabs[0].id;

})}
</ul>
<div className="block" data-cy="TabContent">
{tabs.find(tab => tab.id === validTabId)?.content}

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)

Copy link

@StasSokolov1 StasSokolov1 left a 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 })}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants