Skip to content

Commit 34a039d

Browse files
update readme
1 parent 490a67a commit 34a039d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -833,10 +833,11 @@ Parameters:
833833
**Example**
834834

835835
```js
836-
instance.on('onSelect', function (params) {
836+
const handler = React.useCallback(function (params) {
837837
const {currentSelectedTabId, previousSelectedTabId} = params;
838838
// can use 'this' here which refers to the instance
839-
});
839+
}, []);
840+
instance.on('onSelect', handler);
840841
```
841842

842843
### one
@@ -872,12 +873,13 @@ Parameters:
872873
**Example**
873874

874875
```js
875-
const onSelectHandler = function (params) {
876-
const {currentSelectedTabId, previousSelectedTabId} = params;
877-
// can use 'this' here which refers to the instance
878-
this.off('onSelect', onSelectHandler);
876+
const handler = React.useCallback(function () {}, []);
877+
const attachHandler = () => {
878+
instance.on('onSelect', handler);
879+
};
880+
const deattachHandler = () => {
881+
instance.off('onSelect', handler);
879882
};
880-
instance.on('onSelect', onSelectHandler);
881883
```
882884

883885
### getData

0 commit comments

Comments
 (0)