22
33React Dynamic Tabs with full API
44
5+ > _ Support react >= ` v16.8.0 ` _
6+
57### [ Demo] ( https://dev-javascript.github.io/react-dyn-tabs/ )
68
79## Features
@@ -144,9 +146,13 @@ export default () => {
144146 });
145147 const addTab3 = function () {
146148 // open tab 3
147- _instance .open ({id: ' 3' , title: ' Tab 3' , panelComponent : (porps ) => < p> panel 3 < / p> });
149+ _instance .open ({id: ' 3' , title: ' Tab 3' , panelComponent : (porps ) => < p> panel 3 < / p> }).then (() => {
150+ console .log (' tab 3 is open' );
151+ });
148152 // switch to tab 3
149- _instance .select (' 3' );
153+ _instance .select (' 3' ).then (() => {
154+ console .log (' tab 3 is selected' );
155+ });
150156 };
151157 return (
152158 <>
@@ -864,7 +870,6 @@ Parameters:
864870``` js
865871const handler = React .useCallback (function (params ) {
866872 const {currentSelectedTabId , previousSelectedTabId } = params;
867- // can use 'this' here which refers to the instance
868873}, []);
869874instance .on (' onSelect' , handler);
870875```
@@ -883,9 +888,7 @@ Parameters:
883888** Example**
884889
885890``` js
886- instance .one (' onSelect' , function ({currentSelectedTabId, previousSelectedTabId}) {
887- // can use 'this' here which refers to the instance
888- });
891+ instance .one (' onSelect' , function ({currentSelectedTabId, previousSelectedTabId}) {});
889892```
890893
891894### off
0 commit comments