execute a function on tab click antd

Solutions on MaxInterview for execute a function on tab click antd by the best coders in the world

showing results for - "execute a function on tab click antd"
Desiree
07 Oct 2019
1class App extends React.Component {
2  
3  const [activeTabKey, setActiveTabKey] = React.useState('1');
4
5  const changeTab = activeKey => {
6    console.log(activeKey);
7    setActiveTabKey(activeKey);
8  };
9
10useEffect(() => {
11    if (activeTabKey === '1') {
12      setData(true);
13    }
14
15    if (activeTabKey === '2') {
16      setProductData(true);
17    }
18
19    if (activeTabKey === '3') {
20      setProductsData(true);
21    }
22
23    if (activeTabKey === '4') {
24      setSoldData(true);
25    }
26
27    if (activeTabKey === '5') {
28      setArchivedData(true);
29    }
30  }, [activeTabKey]);
31  
32  
33    return (
34     <Tabs
35        className="ant-tabs-home"
36        defaultActiveKey="1"
37        activeKey={activeTabKey}
38        onChange={changeTab}
39      >
40        <TabPane
41          key="1"
42          
43          onClick={() => setIsActionsData(true)}
44        >
45.........
46.....
47....
48...
49..
50.
51)
52}}
53