Commit b9be27e
fix: Add null check in destroy() before disconnecting sensor (#21)
* fix: Add null check in destroy() before disconnecting sensor
Fixes a TypeError that occurs when sensor.disconnect() is called
on an already destroyed sensor during React StrictMode's double
mount/unmount cycle.
The destroy() function attempted to call sensor.disconnect()
without checking if sensor was still defined, leading to:
"TypeError: Cannot read properties of undefined (reading 'disconnect')"
This commonly occurs in React 18+ StrictMode environments where
components are intentionally mounted and unmounted twice to detect
side effects, causing multiple destroy() calls on the same sensor.
* Bump version from 1.0.2 to 1.0.3
---------
Co-authored-by: hustcc <[email protected]>1 parent 7df9633 commit b9be27e
2 files changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
0 commit comments