Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
fix: unexpectedly invoke initSessionAndConnect twice when use it in u…
Browse files Browse the repository at this point in the history
…seEffect
  • Loading branch information
pjchender committed Feb 7, 2020
1 parent 763db72 commit 7cd6f86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ See our demo site: [react-use-opentok](https://pjchender.github.io/react-use-ope
Install it with npm:

```
npm i react-use-opentok --save
npm i @opentok/client@2.x react-use-opentok
```

Or with yarn:

```
yarn add react-use-opentok
yarn add @opentok/client@2.x react-use-opentok
```

> NOTE: remember to install the peer dependency of [@opentok/client](https://www.npmjs.com/package/@opentok/client)
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ const useOpenTok = () => {
);

const connectSession = useCallback(
(token, sessionToConnect = session) =>
(token, sessionToConnect) =>
new Promise((resolve, reject) => {
if (!token) {
reject('[react-use-opentok] token does not exist.');
return reject('[react-use-opentok] token does not exist.');
}

if (!sessionToConnect) {
reject('[react-use-opentok] session does not exist.');
return reject('[react-use-opentok] session does not exist.');
}

sessionToConnect.connect(token, error => {
Expand All @@ -92,7 +92,7 @@ const useOpenTok = () => {
}
});
}),
[action, session]
[action]
);

const initSessionAndConnect = useCallback(
Expand Down

0 comments on commit 7cd6f86

Please sign in to comment.