Reputation: 193
I have 3 lightning tabs. I want to run a particular piece of code on switching between these tabs. Is there a way I can do it. I tried writing the code in renderedCallback and connectedCallback, but none of these methods are called on switching between tabs.
Upvotes: 1
Views: 7936
Reputation: 3
You could add onactive in your markup
<lightning-tabset active-tab-value={activeTab}>
<lightning-tab label="Item One" onactive={handleClick} value="one">
One Content !
</lightning-tab>
<lightning-tab label="Item Two" onactive={handleClick} value="two">
Two Content !
</lightning-tab>
<lightning-tab label="Item Three" onactive={handleCLick} value="three">
Three Content !
</lightning-tab>
Upvotes: 0