Skip to content

Commit f62e207

Browse files
fix(react-native): process.nextTick is not a function error (#1849)
* 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 <[email protected]>
1 parent d424ae2 commit f62e207

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

package-lock.json

Lines changed: 7 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/connect/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import MqttClient, {
99
import IS_BROWSER from '../is-browser'
1010
import { StreamBuilder } from '../shared'
1111

12+
// Handling the process.nextTick is not a function error in react-native applications.
13+
if (typeof process?.nextTick !== 'function') {
14+
process.nextTick = setImmediate
15+
}
16+
1217
const debug = _debug('mqttjs')
1318

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

0 commit comments

Comments
 (0)