Skip to content

Commit

Permalink
fix(network): Don't add window event listeners if there is no window (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Nov 2, 2021
1 parent a49c590 commit 0c65780
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions network/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ function translatedConnection(): ConnectionType {
export class NetworkWeb extends WebPlugin implements NetworkPlugin {
constructor() {
super();
window.addEventListener('online', this.handleOnline);
window.addEventListener('offline', this.handleOffline);
if (typeof window !== 'undefined') {
window.addEventListener('online', this.handleOnline);
window.addEventListener('offline', this.handleOffline);
}
}

async getStatus(): Promise<ConnectionStatus> {
Expand Down

0 comments on commit 0c65780

Please sign in to comment.