@ninetailed/experience.js-react 7.3.2 → 7.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +17 -4
- package/index.js +17 -4
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -471,7 +471,8 @@ const Experience = _a => {
|
|
|
471
471
|
baseline = __rest(_a, ["experiences", "component", "loadingComponent", "passthroughProps"]);
|
|
472
472
|
const {
|
|
473
473
|
observeElement,
|
|
474
|
-
unobserveElement
|
|
474
|
+
unobserveElement,
|
|
475
|
+
logger
|
|
475
476
|
} = useNinetailed();
|
|
476
477
|
// TODO we actually could hook into the experience hook here with the plugins
|
|
477
478
|
const {
|
|
@@ -492,6 +493,15 @@ const Experience = _a => {
|
|
|
492
493
|
const componentRef = React.useRef(null);
|
|
493
494
|
React.useEffect(() => {
|
|
494
495
|
const componentElement = componentRef.current;
|
|
496
|
+
if (componentElement && !(componentElement instanceof Element)) {
|
|
497
|
+
const isObject = typeof componentElement === 'object' && componentElement !== null;
|
|
498
|
+
const constructorName = isObject ? componentElement.constructor.name : '';
|
|
499
|
+
const isConstructorNameNotObject = constructorName && constructorName !== 'Object';
|
|
500
|
+
logger.warn(`The component ref being in Experience is an invalid element. Expected an Element but got ${typeof componentElement}${isConstructorNameNotObject ? ` of type ${constructorName}` : ''}. This component won't be observed.`);
|
|
501
|
+
return () => {
|
|
502
|
+
// noop
|
|
503
|
+
};
|
|
504
|
+
}
|
|
495
505
|
if (componentElement) {
|
|
496
506
|
observeElement({
|
|
497
507
|
element: componentElement,
|
|
@@ -500,11 +510,14 @@ const Experience = _a => {
|
|
|
500
510
|
variant,
|
|
501
511
|
variantIndex
|
|
502
512
|
});
|
|
513
|
+
return () => {
|
|
514
|
+
if (componentElement) {
|
|
515
|
+
unobserveElement(componentElement);
|
|
516
|
+
}
|
|
517
|
+
};
|
|
503
518
|
}
|
|
504
519
|
return () => {
|
|
505
|
-
|
|
506
|
-
unobserveElement(componentElement);
|
|
507
|
-
}
|
|
520
|
+
// noop
|
|
508
521
|
};
|
|
509
522
|
}, [observeElement, unobserveElement, experience, baseline, variant, variantIndex, audience]);
|
|
510
523
|
if (!hasVariants) {
|
package/index.js
CHANGED
|
@@ -463,7 +463,8 @@ const Experience = _a => {
|
|
|
463
463
|
baseline = __rest(_a, ["experiences", "component", "loadingComponent", "passthroughProps"]);
|
|
464
464
|
const {
|
|
465
465
|
observeElement,
|
|
466
|
-
unobserveElement
|
|
466
|
+
unobserveElement,
|
|
467
|
+
logger
|
|
467
468
|
} = useNinetailed();
|
|
468
469
|
// TODO we actually could hook into the experience hook here with the plugins
|
|
469
470
|
const {
|
|
@@ -484,6 +485,15 @@ const Experience = _a => {
|
|
|
484
485
|
const componentRef = useRef(null);
|
|
485
486
|
useEffect(() => {
|
|
486
487
|
const componentElement = componentRef.current;
|
|
488
|
+
if (componentElement && !(componentElement instanceof Element)) {
|
|
489
|
+
const isObject = typeof componentElement === 'object' && componentElement !== null;
|
|
490
|
+
const constructorName = isObject ? componentElement.constructor.name : '';
|
|
491
|
+
const isConstructorNameNotObject = constructorName && constructorName !== 'Object';
|
|
492
|
+
logger.warn(`The component ref being in Experience is an invalid element. Expected an Element but got ${typeof componentElement}${isConstructorNameNotObject ? ` of type ${constructorName}` : ''}. This component won't be observed.`);
|
|
493
|
+
return () => {
|
|
494
|
+
// noop
|
|
495
|
+
};
|
|
496
|
+
}
|
|
487
497
|
if (componentElement) {
|
|
488
498
|
observeElement({
|
|
489
499
|
element: componentElement,
|
|
@@ -492,11 +502,14 @@ const Experience = _a => {
|
|
|
492
502
|
variant,
|
|
493
503
|
variantIndex
|
|
494
504
|
});
|
|
505
|
+
return () => {
|
|
506
|
+
if (componentElement) {
|
|
507
|
+
unobserveElement(componentElement);
|
|
508
|
+
}
|
|
509
|
+
};
|
|
495
510
|
}
|
|
496
511
|
return () => {
|
|
497
|
-
|
|
498
|
-
unobserveElement(componentElement);
|
|
499
|
-
}
|
|
512
|
+
// noop
|
|
500
513
|
};
|
|
501
514
|
}, [observeElement, unobserveElement, experience, baseline, variant, variantIndex, audience]);
|
|
502
515
|
if (!hasVariants) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-react",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=16.8.0"
|
|
6
6
|
},
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"types": "./index.d.ts",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@ninetailed/experience.js": "7.
|
|
12
|
+
"@ninetailed/experience.js": "7.4.1",
|
|
13
13
|
"react-is": "18.2.0",
|
|
14
|
-
"@ninetailed/experience.js-shared": "7.
|
|
14
|
+
"@ninetailed/experience.js-shared": "7.4.1",
|
|
15
15
|
"radash": "10.9.0",
|
|
16
16
|
"react-intersection-observer": "8.34.0"
|
|
17
17
|
}
|