@@ -983,48 +983,66 @@ const {selectedTabID, openTabIDs} = instance.getPreviousData();
983
983
<th>type</th>
984
984
<th>default value</th>
985
985
<th>required</th>
986
+ <th>description</th>
986
987
</tr>
987
988
<tr>
988
989
<td>id</td>
989
990
<td>string</td>
990
991
<td></td>
991
992
<td>false</td>
993
+ <td>a unique identifier for each tab</td>
992
994
</tr>
993
995
<tr>
994
996
<td>title</td>
995
997
<td>string</td>
996
998
<td>' '</td>
997
999
<td>false</td>
1000
+ <td></td>
998
1001
</tr>
999
1002
<tr>
1000
1003
<td>tooltip</td>
1001
1004
<td>string</td>
1002
1005
<td>' '</td>
1003
1006
<td>false</td>
1007
+ <td></td>
1004
1008
</tr>
1005
1009
<tr>
1006
1010
<td>panelComponent</td>
1007
1011
<td>React Element | React Component | null</td>
1008
1012
<td>A function component which returns empty div</td>
1009
1013
<td>false</td>
1014
+ <td></td>
1015
+ </tr>
1016
+ <tr>
1017
+ <td>lazy</td>
1018
+ <td>boolean</td>
1019
+ <td>false</td>
1020
+ <td>false</td>
1021
+ <td>
1022
+ If set to false the panel will be rendered initially.
1023
+ if set to true the panel will not be rendered until the tab is activated
1024
+ </td>
1010
1025
</tr>
1011
1026
<tr>
1012
1027
<td>closable</td>
1013
1028
<td>boolean</td>
1014
1029
<td>true</td>
1015
1030
<td>false</td>
1031
+ <td></td>
1016
1032
</tr>
1017
1033
<tr>
1018
1034
<td>iconClass</td>
1019
1035
<td>string</td>
1020
1036
<td>' '</td>
1021
1037
<td>false</td>
1038
+ <td>class name for the icon</td>
1022
1039
</tr>
1023
1040
<tr>
1024
1041
<td>disable</td>
1025
1042
<td>boolean</td>
1026
1043
<td>false</td>
1027
1044
<td>false</td>
1045
+ <td></td>
1028
1046
</tr>
1029
1047
</tbody >
1030
1048
</table >
@@ -1037,6 +1055,7 @@ const tabData = {
1037
1055
title: ' contactTitle' ,
1038
1056
tooltip: ' contactTooltip' ,
1039
1057
disable: true ,
1058
+ lazy: true ,
1040
1059
iconClass: ' fa fa-home' ,
1041
1060
closable: false ,
1042
1061
panelComponent : (porps ) => < p> contact content < / p> ,
@@ -1050,7 +1069,57 @@ if (instance.isOpen(tabData.id) == false) {
1050
1069
1051
1070
## Lazy Loading
1052
1071
1053
- upcoming...
1072
+ Defer loading of tab content until the tab is activated
1073
+
1074
+ Example 1
1075
+
1076
+ ``` js
1077
+ const Panel3 = React .lazy (() => import (' ./components/panel3.js' ));
1078
+ function LazyLoadingPanel3 (porps ) {
1079
+ return (
1080
+ < Suspense fallback= {< div> Loading... < / div> }>
1081
+ < Panel3 {... porps}>< / Panel3>
1082
+ < / Suspense>
1083
+ );
1084
+ }
1085
+ useDynTabs ({
1086
+ tabs: [
1087
+ {id: ' 1' , title: ' eager loading tab 1' , panelComponent: < p> panel 1 < / p> },
1088
+ {id: ' 2' , title: ' eager loading tab 2' , lazy: true , panelComponent: < p> panel 2 < / p> },
1089
+ {id: ' 3' , title: ' lazy loading tab 3' , lazy: true , panelComponent: LazyLoadingPanel3},
1090
+ ],
1091
+ selectedTabID: ' 1' ,
1092
+ });
1093
+ ```
1094
+
1095
+ ** NOTE :**
1096
+
1097
+ - panel 1 is eagerly loaded and rendered.
1098
+ - panel 2 is eagerly loaded but will not be rendered until tab 2 is activated.
1099
+ - panel 3 will not be loaded and rendered until tab 3 is activated.
1100
+
1101
+ Example 2 ( using onFirstSelect event )
1102
+
1103
+ ``` js
1104
+ useDynTabs ({
1105
+ tabs: [
1106
+ {id: ' 1' , title: ' eager loading tab 1' , panelComponent: < p> panel 1 < / p> },
1107
+ {id: ' 2' , title: ' eager loading tab 2' , lazy: true , panelComponent: < p> panel 2 < / p> },
1108
+ {id: ' 3' , title: ' lazy loading tab 3' , lazy: true , panelComponent: < div> Loading... < / div> },
1109
+ ],
1110
+ onFirstSelect : function ({currentSelectedTabId, previousSelectedTabId}) {
1111
+ const instance = this ;
1112
+ if (currentSelectedTabId === ' 3' ) {
1113
+ import (' ./components/panel3.js' ).then ((defaultExportedModule ) => {
1114
+ const Panel3 = defaultExportedModule .default ;
1115
+ instance .setTab (' 3' , {panelComponent: Panel3});
1116
+ instance .refresh ();
1117
+ });
1118
+ }
1119
+ },
1120
+ selectedTabID: ' 1' ,
1121
+ });
1122
+ ```
1054
1123
1055
1124
## Styling
1056
1125
@@ -1065,7 +1134,7 @@ import 'react-dyn-tabs/themes/react-dyn-tabs-card.min.css';
1065
1134
1066
1135
** NOTE :**
1067
1136
1068
- You can find other themes at themes folder.
1137
+ You can find other themes at themes folder and multiple themes example at example/multi-themes-example folder .
1069
1138
1070
1139
## Caveats
1071
1140
0 commit comments