2
2
3
3
React Dynamic Tabs with full API
4
4
5
+ > _ Support react >= ` v16.8.0 ` _
6
+
5
7
### [ Demo] ( https://dev-javascript.github.io/react-dyn-tabs/ )
6
8
7
9
## Features
@@ -144,9 +146,13 @@ export default () => {
144
146
});
145
147
const addTab3 = function () {
146
148
// 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
+ });
148
152
// switch to tab 3
149
- _instance .select (' 3' );
153
+ _instance .select (' 3' ).then (() => {
154
+ console .log (' tab 3 is selected' );
155
+ });
150
156
};
151
157
return (
152
158
<>
@@ -864,7 +870,6 @@ Parameters:
864
870
``` js
865
871
const handler = React .useCallback (function (params ) {
866
872
const {currentSelectedTabId , previousSelectedTabId } = params;
867
- // can use 'this' here which refers to the instance
868
873
}, []);
869
874
instance .on (' onSelect' , handler);
870
875
```
@@ -883,9 +888,7 @@ Parameters:
883
888
** Example**
884
889
885
890
``` 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}) {});
889
892
```
890
893
891
894
### off
0 commit comments