Skip to content

Commit

Permalink
fix(react-native): process.nextTick is not a function error (#1849)
Browse files Browse the repository at this point in the history
* fix:  React Native App - TypeError: process.nextTick is not a function (it is undefined)

This is to fix - process.nextTick is not a function (it is undefined) - error in react native apps.

* lint fixing

---------

Co-authored-by: abdelhameedalsayed <abdulhameed.azab@gmail.com>
  • Loading branch information
abdelhameedhamdy and abdelhameedalsayed committed Apr 22, 2024
1 parent d424ae2 commit f62e207
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
21 changes: 7 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/lib/connect/index.ts
Expand Up @@ -9,6 +9,11 @@ import MqttClient, {
import IS_BROWSER from '../is-browser'
import { StreamBuilder } from '../shared'

// Handling the process.nextTick is not a function error in react-native applications.
if (typeof process?.nextTick !== 'function') {
process.nextTick = setImmediate
}

const debug = _debug('mqttjs')

const protocols: Record<string, StreamBuilder> = {}
Expand Down

0 comments on commit f62e207

Please sign in to comment.