Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element'. #184

Open
shahnad opened this issue Oct 17, 2022 · 1 comment

Comments

@shahnad
Copy link

shahnad commented Oct 17, 2022

Hi,
I don't know why this happening.
if anyone can reproduce it. it will be appreciatable. Thanks

"react-range": "^1.8.14",

image

@bertuck
Copy link

bertuck commented Mar 22, 2023

Patch to apply via patch-package to resolve issue : (waiting for PR to be merged #182)

react-range+1.8.14.patch

diff --git a/node_modules/react-range/lib/Range.js b/node_modules/react-range/lib/Range.js
index 2403f9d..f276ec3 100644
--- a/node_modules/react-range/lib/Range.js
+++ b/node_modules/react-range/lib/Range.js
@@ -68,6 +68,10 @@ var Range = /** @class */ (function (_super) {
         _this.getOffsets = function () {
             var _a = _this.props, direction = _a.direction, values = _a.values, min = _a.min, max = _a.max;
             var trackElement = _this.trackRef.current;
+            if (!trackElement) {
+                console.warn('No track element found.');
+                return [];
+            }
             var trackRect = trackElement.getBoundingClientRect();
             var trackPadding = (0, utils_1.getPaddingAndBorder)(trackElement);
             return _this.getThumbs().map(function (thumb, index) {
@@ -523,7 +527,9 @@ var Range = /** @class */ (function (_super) {
         document.removeEventListener('touchstart', this.onMouseOrTouchStart);
         document.removeEventListener('mouseup', this.schdOnEnd);
         document.removeEventListener('touchend', this.schdOnEnd);
-        this.resizeObserver.unobserve(this.trackRef.current);
+        if (this.trackRef && this.trackRef.current) {
+            this.resizeObserver.unobserve(this.trackRef.current);
+        }
     };
     Range.prototype.render = function () {
         var _this = this;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants