Skip to content

Commit 3263211

Browse files
update readme
1 parent ac653e0 commit 3263211

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

README.md

+18-31
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export default () => {
167167

168168
**NOTE :**
169169

170-
- Tabs can't be manipulated safely before the first render, use ready() to make a function available after the component is mounted.
170+
- Tabs can't be manipulated safely before the first render, use ready() to access the instance object when the component is mounted.
171171

172172
- ready function and instance Object will not be changed after re-rendering multiple times.
173173

@@ -232,7 +232,7 @@ const [TabList, PanelList, ready] = useDynTabs({
232232
<td>string</td>
233233
<td>' '</td>
234234
<td>false</td>
235-
<td>initial selected tab id</td>
235+
<td>specifies initial selected tab</td>
236236
</tr>
237237
</tbody>
238238
</table>
@@ -345,7 +345,7 @@ Default value for panelComponent option.
345345
const [TabList, PanelList, ready] = useDynTabs({
346346
defaultPanelComponent: (props) => {
347347
const {id, isSelected, api: instance} = props;
348-
return <div></div>;
348+
return <div>loading...</div>;
349349
},
350350
});
351351
```
@@ -377,7 +377,7 @@ const [TabList, PanelList, ready] = useDynTabs({accessibility: false});
377377

378378
**NOTE :**
379379

380-
This option assigns id attribute on panel element and button element inside the tab. for having elements without id attribute, set this option to false.
380+
When accessibility option is true, it sets the id attribute of panel and button elements.
381381

382382
### isVertical
383383

@@ -416,7 +416,7 @@ const [TabList, PanelList, ready] = useDynTabs({isVertical: true});
416416
<tr>
417417
<td>function</td>
418418
<td>false</td>
419-
<td>This event is fired only once, after first render</td>
419+
<td>This event is fired only once, after the first render</td>
420420
</tr>
421421
</tbody>
422422
</table>
@@ -433,7 +433,7 @@ const [TabList, PanelList, ready] = useDynTabs({
433433

434434
**NOTE :**
435435

436-
You can use 'this' keyword inside all callback options which refers to the instance object.
436+
You can use 'this' keyword inside all callback options. It refers to the instance object.
437437

438438
### onInit
439439

@@ -563,7 +563,7 @@ const [TabList, PanelList, ready] = useDynTabs({
563563
<tr>
564564
<td>function</td>
565565
<td>false</td>
566-
<td>fires after selecting tabs. this event is not fired initially</td>
566+
<td>fires after selecting a tab. this event is not fired initially</td>
567567
</tr>
568568
</tbody>
569569
</table>
@@ -708,7 +708,7 @@ const result = instance.isOpen('Your tab ID');
708708

709709
### open
710710

711-
Triggers 'onInit', 'onChange' and 'onOpen' event. opening an already opened tab only triggers 'onInit' event.
711+
Triggers 'onInit', 'onChange' and 'onOpen' event.
712712

713713
Return value : Promise
714714

@@ -756,8 +756,6 @@ Makes current and previous selected tab to be re-rendered
756756

757757
Triggers 'onInit', 'onChange' and 'onSelect' event.
758758

759-
Selecting an already selected tab only triggers 'onInit' event.
760-
761759
Return value : Promise
762760

763761
Parameters:
@@ -778,9 +776,7 @@ if (instance.isSelected('1') == false) {
778776

779777
Triggers 'onInit', 'onChange' and 'onClose' event.
780778

781-
Closing an already closed tab only triggers 'onInit' event.
782-
783-
It switches to the previously selected tab before closing if switching parameter was true and tab was already opened and selected.
779+
When switching parameter is true, it switches to previous selected tab
784780

785781
Return value : Promise
786782

@@ -990,7 +986,7 @@ const {selectedTabID, openTabIDs} = instance.getPreviousData();
990986
<td>string</td>
991987
<td></td>
992988
<td>false</td>
993-
<td>a unique identifier for each tab</td>
989+
<td>an unique identifier for each tab</td>
994990
</tr>
995991
<tr>
996992
<td>title</td>
@@ -1105,19 +1101,22 @@ useDynTabs({
11051101
tabs: [
11061102
{id: '1', title: 'eager loading tab 1', panelComponent: <p>panel 1</p>},
11071103
{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>},
1104+
{id: '3', title: 'lazy loading tab 3', lazy: true},
11091105
],
1110-
onFirstSelect: function ({currentSelectedTabId, previousSelectedTabId}) {
1106+
selectedTabID: '1',
1107+
defaultPanelComponent: function DefaultPanel() {
1108+
return <div>loading...</div>;
1109+
},
1110+
onFirstSelect: function ({currentSelectedTabId}) {
11111111
const instance = this;
11121112
if (currentSelectedTabId === '3') {
1113-
import('./components/panel3.js').then((defaultExportedModule) => {
1113+
import('path to/panel3.js').then((defaultExportedModule) => {
11141114
const Panel3 = defaultExportedModule.default;
11151115
instance.setTab('3', {panelComponent: Panel3});
11161116
instance.refresh();
11171117
});
11181118
}
11191119
},
1120-
selectedTabID: '1',
11211120
});
11221121
```
11231122

@@ -1146,19 +1145,7 @@ You can find other themes at themes folder and multiple themes example at exampl
11461145

11471146
These deprecated features can still be used, but should be used with caution because they are expected to be removed entirely sometime in the future. You should work to remove their use from your code.
11481147

1149-
- Third element of returned array by useDynTabs hook should not be used as an object, it is no longer recommended and only be kept for backwards compatibility purposes, may be removed in the future. Avoid using it as an object and use the code below instead of it.
1150-
1151-
```js
1152-
const [TabList, PanelList, ready] = useDynTabs(options);
1153-
const open_tab_3 = function () {
1154-
ready(function (instance) {
1155-
if (instance.isOpen('3') === false) {
1156-
instance.open({id: '3', title: 'mock tab 3'});
1157-
instance.select('3');
1158-
}
1159-
});
1160-
};
1161-
```
1148+
- Third element of returned array by useDynTabs hook should not be used as an object, it is no longer recommended and only be kept for backwards compatibility purposes, it should be used as a function.
11621149

11631150
- First parameter of onSelect function is an object and has perviousSelectedTabId property which is deprecated. you should use previousSelectedTabId property instead of perviousSelectedTabId property.
11641151

0 commit comments

Comments
 (0)