Skip to content

CTabs active not work properly #433

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

Closed
nighttiger1990 opened this issue May 1, 2025 · 2 comments
Closed

CTabs active not work properly #433

nighttiger1990 opened this issue May 1, 2025 · 2 comments

Comments

@nighttiger1990
Copy link

In the below code. I change activeTab by clicking other button but Tabs not change

import React, { useState } from 'react';
import { CTab, CTabContent, CTabList, CTabPanel, CTabs } from '@coreui/react';

export const TabsControlledExample = () => {
  const [activeTab, setActiveTab] = useState('profile');
  const [tName, setTName] = useState('contact');
  const onClick = () => {
    console.log(tName);
    setActiveTab(tName);
  };

  return (
    <>
      <input defaultValue={tName} onChange={(e) => setTName(e.target.value)} />
      <button onClick={onClick}>click here</button>
      <CTabs activeItemKey={activeTab} onChange={setActiveTab}>
        <CTabList variant="tabs">
          <CTab itemKey="home">Home</CTab>
          <CTab itemKey="profile">Profile</CTab>
          <CTab itemKey="contact">Contact</CTab>
          <CTab disabled itemKey="disabled">
            Disabled
          </CTab>
        </CTabList>
        <CTabContent>
          <CTabPanel className="p-3" itemKey="home">
            Home tab content
          </CTabPanel>
          <CTabPanel className="p-3" itemKey="profile">
            Profile tab content
          </CTabPanel>
          <CTabPanel className="p-3" itemKey="contact">
            Contact tab content
          </CTabPanel>
          <CTabPanel className="p-3" itemKey="disabled">
            Disabled tab content
          </CTabPanel>
        </CTabContent>
      </CTabs>
    </>
  );
};

This is version of package

  "@coreui/coreui": "^5.3.2",
  "@coreui/react": "^5.5.0",

https://stackblitz.com/edit/react-b6qyor97?file=src%2FTabsControlledExample.jsx

@mrholek
Copy link
Member

mrholek commented May 1, 2025

@nighttiger1990 please update @coreui/react to 5.6.0

@nighttiger1990
Copy link
Author

@nighttiger1990 please update @coreui/react to 5.6.0

After updating to @coreui/react:5.6.0 issue gone. Thanks

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

No branches or pull requests

2 participants