@edx/frontend-plugin-learner-dashboard 3.3.3 → 3.3.5
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/dist/dynamic-experience-slot/DynamicExperienceSlot.js +7 -2
- package/dist/dynamic-experience-slot/DynamicExperienceSlot.js.map +1 -1
- package/dist/no-courses-view/index.js +14 -2
- package/dist/no-courses-view/index.js.map +1 -1
- package/dist/package.json +2 -1
- package/package.json +3 -2
- package/src/dynamic-experience-slot/DynamicExperienceSlot.jsx +9 -2
- package/src/no-courses-view/index.jsx +11 -2
- package/src/no-courses-view/index.test.jsx +7 -0
|
@@ -50,20 +50,25 @@ const DynamicExperienceSlot = _ref => {
|
|
|
50
50
|
const UCL = useUCL();
|
|
51
51
|
const [shouldThrow, setShouldThrow] = (0, _react.useState)(false);
|
|
52
52
|
const [error, setError] = (0, _react.useState)(null);
|
|
53
|
+
|
|
54
|
+
// Lock props to prevent unnecessary re-renders
|
|
55
|
+
const restPropsRef = (0, _react.useRef)(rest);
|
|
56
|
+
// Update ref on each render to prevent stale props
|
|
57
|
+
restPropsRef.current = rest;
|
|
53
58
|
(0, _react.useEffect)(() => {
|
|
54
59
|
const refCurrent = ref.current;
|
|
55
60
|
if (!refCurrent || !UCL) {
|
|
56
61
|
return undefined;
|
|
57
62
|
}
|
|
58
63
|
try {
|
|
59
|
-
UCL.mount(widgetName, refCurrent, _objectSpread(_objectSpread({},
|
|
64
|
+
UCL.mount(widgetName, refCurrent, _objectSpread(_objectSpread({}, restPropsRef.current), {}, {
|
|
60
65
|
onFallbackShouldRender: setShouldThrow
|
|
61
66
|
}));
|
|
62
67
|
} catch (e) {
|
|
63
68
|
setError(e);
|
|
64
69
|
}
|
|
65
70
|
return () => UCL.unmount(refCurrent);
|
|
66
|
-
}, [widgetName, UCL
|
|
71
|
+
}, [widgetName, UCL]);
|
|
67
72
|
if (error) {
|
|
68
73
|
throw error;
|
|
69
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicExperienceSlot.js","names":["_react","require","_propTypes","_interopRequireDefault","_jsxRuntime","_excluded","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","_objectWithoutProperties","_objectWithoutPropertiesLoose","n","indexOf","propertyIsEnumerable","hasOwnProperty","useUCL","timeout","ucl","setUcl","useState","window","UCL","useEffect","undefined","start","Date","now","id","setInterval","clearInterval","RenderFallbackSignal","Error","constructor","name","DynamicExperienceSlot","_ref","widgetName","rest","ref","useRef","shouldThrow","setShouldThrow","error","setError","
|
|
1
|
+
{"version":3,"file":"DynamicExperienceSlot.js","names":["_react","require","_propTypes","_interopRequireDefault","_jsxRuntime","_excluded","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","_objectWithoutProperties","_objectWithoutPropertiesLoose","n","indexOf","propertyIsEnumerable","hasOwnProperty","useUCL","timeout","ucl","setUcl","useState","window","UCL","useEffect","undefined","start","Date","now","id","setInterval","clearInterval","RenderFallbackSignal","Error","constructor","name","DynamicExperienceSlot","_ref","widgetName","rest","ref","useRef","shouldThrow","setShouldThrow","error","setError","restPropsRef","current","refCurrent","mount","onFallbackShouldRender","unmount","jsx","propTypes","PropTypes","string","isRequired","_default","exports"],"sources":["../../src/dynamic-experience-slot/DynamicExperienceSlot.jsx"],"sourcesContent":["import { useState, useEffect, useRef } from 'react';\nimport PropTypes from 'prop-types';\n\nfunction useUCL(timeout = 5000) {\n const [ucl, setUcl] = useState(() => window.UCL);\n useEffect(() => {\n if (ucl) { return undefined; }\n const start = Date.now();\n const id = setInterval(() => {\n if (window.UCL) {\n setUcl(window.UCL);\n clearInterval(id);\n } else if (Date.now() - start > timeout) {\n clearInterval(id);\n }\n }, 100);\n return () => clearInterval(id);\n }, [ucl, timeout]);\n return ucl;\n}\nclass RenderFallbackSignal extends Error {\n constructor() {\n super('Render fallback requested by widget');\n this.name = 'RenderFallbackSignal';\n }\n}\n\nconst DynamicExperienceSlot = ({ widgetName, ...rest }) => {\n const ref = useRef(null);\n const UCL = useUCL();\n const [shouldThrow, setShouldThrow] = useState(false);\n const [error, setError] = useState(null);\n\n // Lock props to prevent unnecessary re-renders\n const restPropsRef = useRef(rest);\n // Update ref on each render to prevent stale props\n restPropsRef.current = rest;\n\n useEffect(() => {\n const refCurrent = ref.current;\n if (!refCurrent || !UCL) { return undefined; }\n try {\n UCL.mount(widgetName, refCurrent, {\n ...restPropsRef.current,\n onFallbackShouldRender: setShouldThrow,\n });\n } catch (e) {\n setError(e);\n }\n return () => UCL.unmount(refCurrent);\n }, [widgetName, UCL]);\n if (error) { throw error; }\n if (shouldThrow) { throw new RenderFallbackSignal(); }\n return <div ref={ref} />;\n};\n\nDynamicExperienceSlot.propTypes = {\n widgetName: PropTypes.string.isRequired,\n};\n\nexport default DynamicExperienceSlot;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAmC,IAAAG,WAAA,GAAAH,OAAA;AAAA,MAAAI,SAAA;AAAA,SAAAF,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,QAAAH,CAAA,EAAAI,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAP,CAAA,OAAAM,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA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AACF,IAAI,CAAC;EACjC;EACAO,YAAY,CAACC,OAAO,GAAGR,IAAI;EAE3B,IAAAf,gBAAS,EAAC,MAAM;IACd,MAAMwB,UAAU,GAAGR,GAAG,CAACO,OAAO;IAC9B,IAAI,CAACC,UAAU,IAAI,CAACzB,GAAG,EAAE;MAAE,OAAOE,SAAS;IAAE;IAC7C,IAAI;MACFF,GAAG,CAAC0B,KAAK,CAACX,UAAU,EAAEU,UAAU,EAAAzD,aAAA,CAAAA,aAAA,KAC3BuD,YAAY,CAACC,OAAO;QACvBG,sBAAsB,EAAEP;MAAc,EACvC,CAAC;IACJ,CAAC,CAAC,OAAOnE,CAAC,EAAE;MACVqE,QAAQ,CAACrE,CAAC,CAAC;IACb;IACA,OAAO,MAAM+C,GAAG,CAAC4B,OAAO,CAACH,UAAU,CAAC;EACtC,CAAC,EAAE,CAACV,UAAU,EAAEf,GAAG,CAAC,CAAC;EACrB,IAAIqB,KAAK,EAAE;IAAE,MAAMA,KAAK;EAAE;EAC1B,IAAIF,WAAW,EAAE;IAAE,MAAM,IAAIV,oBAAoB,CAAC,CAAC;EAAE;EACrD,oBAAO,IAAA1D,WAAA,CAAA8E,GAAA;IAAKZ,GAAG,EAAEA;EAAI,CAAE,CAAC;AAC1B,CAAC;AAEDJ,qBAAqB,CAACiB,SAAS,GAAG;EAChCf,UAAU,EAAEgB,kBAAS,CAACC,MAAM,CAACC;AAC/B,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhF,OAAA,GAEa0D,qBAAqB","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _i18n = require("@edx/frontend-platform/i18n");
|
|
9
9
|
var _paragon = require("@openedx/paragon");
|
|
10
10
|
var _icons = require("@openedx/paragon/icons");
|
|
11
|
+
var _reactIntersectionObserver = require("react-intersection-observer");
|
|
11
12
|
var _urls = require("data/services/lms/urls");
|
|
12
13
|
var _emptyCourse = _interopRequireDefault(require("assets/empty-course.svg"));
|
|
13
14
|
var _hooks = require("hooks");
|
|
@@ -27,6 +28,13 @@ const NoCoursesView = () => {
|
|
|
27
28
|
courseSearchUrl
|
|
28
29
|
} = _hooks.reduxHooks.usePlatformSettingsData();
|
|
29
30
|
const viewCorrelationIdRef = (0, _react.useRef)(window.crypto.randomUUID());
|
|
31
|
+
const hasViewEventFired = (0, _react.useRef)(false);
|
|
32
|
+
const {
|
|
33
|
+
ref: exploreCoursesRef,
|
|
34
|
+
inView
|
|
35
|
+
} = (0, _reactIntersectionObserver.useInView)({
|
|
36
|
+
triggerOnce: true
|
|
37
|
+
});
|
|
30
38
|
const handleExploreCoursesViewed = (0, _react.useCallback)(() => {
|
|
31
39
|
(0, _exploreCourses.exploreCoursesViewedCohesion)(viewCorrelationIdRef.current);
|
|
32
40
|
}, []);
|
|
@@ -34,8 +42,11 @@ const NoCoursesView = () => {
|
|
|
34
42
|
(0, _exploreCourses.exploreCoursesClickedCohesion)(viewCorrelationIdRef.current);
|
|
35
43
|
};
|
|
36
44
|
(0, _react.useEffect)(() => {
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
if (!hasViewEventFired.current && inView) {
|
|
46
|
+
handleExploreCoursesViewed();
|
|
47
|
+
hasViewEventFired.current = true;
|
|
48
|
+
}
|
|
49
|
+
}, [handleExploreCoursesViewed, inView]);
|
|
39
50
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
40
51
|
id: "no-courses-content-view",
|
|
41
52
|
className: "d-flex align-items-center justify-content-center mb-4.5",
|
|
@@ -53,6 +64,7 @@ const NoCoursesView = () => {
|
|
|
53
64
|
onClick: handleExploreCoursesClick,
|
|
54
65
|
href: (0, _urls.baseAppUrl)(courseSearchUrl),
|
|
55
66
|
iconBefore: _icons.Search,
|
|
67
|
+
ref: exploreCoursesRef,
|
|
56
68
|
children: formatMessage(_messages.default.exploreCoursesButton)
|
|
57
69
|
})]
|
|
58
70
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_i18n","_paragon","_icons","_urls","_emptyCourse","_interopRequireDefault","_hooks","_exploreCourses","_messages","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NoCoursesView","formatMessage","useIntl","courseSearchUrl","reduxHooks","usePlatformSettingsData","viewCorrelationIdRef","useRef","window","crypto","randomUUID","handleExploreCoursesViewed","useCallback","exploreCoursesViewedCohesion","current","handleExploreCoursesClick","exploreCoursesClickedCohesion","useEffect","jsxs","id","className","children","jsx","Image","src","emptyCourseSVG","alt","messages","bannerAlt","lookingForChallengePrompt","exploreCoursesPrompt","Button","variant","as","onClick","href","baseAppUrl","iconBefore","Search","exploreCoursesButton","_default","exports"],"sources":["../../src/no-courses-view/index.jsx"],"sourcesContent":["/* eslint-disable import/no-unresolved */\nimport React, { useCallback, useEffect, useRef } from 'react';\nimport { useIntl } from '@edx/frontend-platform/i18n';\nimport { Button, Image } from '@openedx/paragon';\nimport { Search } from '@openedx/paragon/icons';\nimport { baseAppUrl } from 'data/services/lms/urls';\n\nimport emptyCourseSVG from 'assets/empty-course.svg';\nimport { reduxHooks } from 'hooks';\nimport { exploreCoursesViewedCohesion, exploreCoursesClickedCohesion } from '../tracking/trackers/exploreCourses';\n\nimport messages from './messages';\nimport './index.scss';\n\nconst NoCoursesView = () => {\n const { formatMessage } = useIntl();\n const { courseSearchUrl } = reduxHooks.usePlatformSettingsData();\n const viewCorrelationIdRef = useRef(window.crypto.randomUUID());\n\n const handleExploreCoursesViewed = useCallback(() => {\n exploreCoursesViewedCohesion(viewCorrelationIdRef.current);\n }, []);\n\n const handleExploreCoursesClick = () => {\n exploreCoursesClickedCohesion(viewCorrelationIdRef.current);\n };\n\n useEffect(() => {\n handleExploreCoursesViewed();\n }, [handleExploreCoursesViewed]);\n\n return (\n <div\n id=\"no-courses-content-view\"\n className=\"d-flex align-items-center justify-content-center mb-4.5\"\n >\n <Image src={emptyCourseSVG} alt={formatMessage(messages.bannerAlt)} />\n <h3 className=\"h1\">\n {formatMessage(messages.lookingForChallengePrompt)}\n </h3>\n <p>\n {formatMessage(messages.exploreCoursesPrompt)}\n </p>\n <Button\n variant=\"brand\"\n as=\"a\"\n onClick={handleExploreCoursesClick}\n href={baseAppUrl(courseSearchUrl)}\n iconBefore={Search}\n >\n {formatMessage(messages.exploreCoursesButton)}\n </Button>\n </div>\n );\n};\n\nexport default NoCoursesView;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_i18n","_paragon","_icons","_reactIntersectionObserver","_urls","_emptyCourse","_interopRequireDefault","_hooks","_exploreCourses","_messages","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NoCoursesView","formatMessage","useIntl","courseSearchUrl","reduxHooks","usePlatformSettingsData","viewCorrelationIdRef","useRef","window","crypto","randomUUID","hasViewEventFired","ref","exploreCoursesRef","inView","useInView","triggerOnce","handleExploreCoursesViewed","useCallback","exploreCoursesViewedCohesion","current","handleExploreCoursesClick","exploreCoursesClickedCohesion","useEffect","jsxs","id","className","children","jsx","Image","src","emptyCourseSVG","alt","messages","bannerAlt","lookingForChallengePrompt","exploreCoursesPrompt","Button","variant","as","onClick","href","baseAppUrl","iconBefore","Search","exploreCoursesButton","_default","exports"],"sources":["../../src/no-courses-view/index.jsx"],"sourcesContent":["/* eslint-disable import/no-unresolved */\nimport React, { useCallback, useEffect, useRef } from 'react';\nimport { useIntl } from '@edx/frontend-platform/i18n';\nimport { Button, Image } from '@openedx/paragon';\nimport { Search } from '@openedx/paragon/icons';\nimport { useInView } from 'react-intersection-observer';\n\nimport { baseAppUrl } from 'data/services/lms/urls';\n\nimport emptyCourseSVG from 'assets/empty-course.svg';\nimport { reduxHooks } from 'hooks';\nimport { exploreCoursesViewedCohesion, exploreCoursesClickedCohesion } from '../tracking/trackers/exploreCourses';\n\nimport messages from './messages';\nimport './index.scss';\n\nconst NoCoursesView = () => {\n const { formatMessage } = useIntl();\n const { courseSearchUrl } = reduxHooks.usePlatformSettingsData();\n const viewCorrelationIdRef = useRef(window.crypto.randomUUID());\n const hasViewEventFired = useRef(false);\n\n const { ref: exploreCoursesRef, inView } = useInView({ triggerOnce: true });\n\n const handleExploreCoursesViewed = useCallback(() => {\n exploreCoursesViewedCohesion(viewCorrelationIdRef.current);\n }, []);\n\n const handleExploreCoursesClick = () => {\n exploreCoursesClickedCohesion(viewCorrelationIdRef.current);\n };\n\n useEffect(() => {\n if (!hasViewEventFired.current && inView) {\n handleExploreCoursesViewed();\n hasViewEventFired.current = true;\n }\n }, [handleExploreCoursesViewed, inView]);\n\n return (\n <div\n id=\"no-courses-content-view\"\n className=\"d-flex align-items-center justify-content-center mb-4.5\"\n >\n <Image src={emptyCourseSVG} alt={formatMessage(messages.bannerAlt)} />\n <h3 className=\"h1\">\n {formatMessage(messages.lookingForChallengePrompt)}\n </h3>\n <p>\n {formatMessage(messages.exploreCoursesPrompt)}\n </p>\n <Button\n variant=\"brand\"\n as=\"a\"\n onClick={handleExploreCoursesClick}\n href={baseAppUrl(courseSearchUrl)}\n iconBefore={Search}\n ref={exploreCoursesRef}\n >\n {formatMessage(messages.exploreCoursesButton)}\n </Button>\n </div>\n );\n};\n\nexport default NoCoursesView;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,0BAAA,GAAAJ,O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CAACgC,iBAAQ,CAACC,SAAS;IAAE,CAAE,CAAC,eACtE,IAAAtD,WAAA,CAAAgD,GAAA;MAAIF,SAAS,EAAC,IAAI;MAAAC,QAAA,EACf1B,aAAa,CAACgC,iBAAQ,CAACE,yBAAyB;IAAC,CAChD,CAAC,eACL,IAAAvD,WAAA,CAAAgD,GAAA;MAAAD,QAAA,EACG1B,aAAa,CAACgC,iBAAQ,CAACG,oBAAoB;IAAC,CAC5C,CAAC,eACJ,IAAAxD,WAAA,CAAAgD,GAAA,EAACzD,QAAA,CAAAkE,MAAM;MACLC,OAAO,EAAC,OAAO;MACfC,EAAE,EAAC,GAAG;MACNC,OAAO,EAAEnB,yBAA0B;MACnCoB,IAAI,EAAE,IAAAC,gBAAU,EAACvC,eAAe,CAAE;MAClCwC,UAAU,EAAEC,aAAO;MACnBhC,GAAG,EAAEC,iBAAkB;MAAAc,QAAA,EAEtB1B,aAAa,CAACgC,iBAAQ,CAACY,oBAAoB;IAAC,CACvC,CAAC;EAAA,CACN,CAAC;AAEV,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhE,OAAA,GAEaiB,aAAa","ignoreList":[]}
|
package/dist/package.json
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@optimizely/react-sdk": "^3.2.2",
|
|
37
37
|
"jest-environment-jsdom": "^30.0.0",
|
|
38
38
|
"lodash": "^4.17.21",
|
|
39
|
+
"react-intersection-observer": "^10.0.3",
|
|
39
40
|
"react-redux": "^7.2.4",
|
|
40
41
|
"react-responsive": "^10.0.0",
|
|
41
42
|
"reselect": "^5.1.1"
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"@openedx/frontend-build": "14.6.2",
|
|
48
49
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
50
|
"@testing-library/react": "^16.2.0",
|
|
50
|
-
"jest": "30.
|
|
51
|
+
"jest": "30.3.0",
|
|
51
52
|
"react-error-boundary": "^6.1.0",
|
|
52
53
|
"rosie": "2.1.1",
|
|
53
54
|
"semantic-release": "^25.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edx/frontend-plugin-learner-dashboard",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.5",
|
|
4
4
|
"description": "Repository for Learner Dashboard MFE frontend plugins",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@optimizely/react-sdk": "^3.2.2",
|
|
37
37
|
"jest-environment-jsdom": "^30.0.0",
|
|
38
38
|
"lodash": "^4.17.21",
|
|
39
|
+
"react-intersection-observer": "^10.0.3",
|
|
39
40
|
"react-redux": "^7.2.4",
|
|
40
41
|
"react-responsive": "^10.0.0",
|
|
41
42
|
"reselect": "^5.1.1"
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"@openedx/frontend-build": "14.6.2",
|
|
48
49
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
50
|
"@testing-library/react": "^16.2.0",
|
|
50
|
-
"jest": "30.
|
|
51
|
+
"jest": "30.3.0",
|
|
51
52
|
"react-error-boundary": "^6.1.0",
|
|
52
53
|
"rosie": "2.1.1",
|
|
53
54
|
"semantic-release": "^25.0.0",
|
|
@@ -24,24 +24,31 @@ class RenderFallbackSignal extends Error {
|
|
|
24
24
|
this.name = 'RenderFallbackSignal';
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
|
|
27
28
|
const DynamicExperienceSlot = ({ widgetName, ...rest }) => {
|
|
28
29
|
const ref = useRef(null);
|
|
29
30
|
const UCL = useUCL();
|
|
30
31
|
const [shouldThrow, setShouldThrow] = useState(false);
|
|
31
32
|
const [error, setError] = useState(null);
|
|
33
|
+
|
|
34
|
+
// Lock props to prevent unnecessary re-renders
|
|
35
|
+
const restPropsRef = useRef(rest);
|
|
36
|
+
// Update ref on each render to prevent stale props
|
|
37
|
+
restPropsRef.current = rest;
|
|
38
|
+
|
|
32
39
|
useEffect(() => {
|
|
33
40
|
const refCurrent = ref.current;
|
|
34
41
|
if (!refCurrent || !UCL) { return undefined; }
|
|
35
42
|
try {
|
|
36
43
|
UCL.mount(widgetName, refCurrent, {
|
|
37
|
-
...
|
|
44
|
+
...restPropsRef.current,
|
|
38
45
|
onFallbackShouldRender: setShouldThrow,
|
|
39
46
|
});
|
|
40
47
|
} catch (e) {
|
|
41
48
|
setError(e);
|
|
42
49
|
}
|
|
43
50
|
return () => UCL.unmount(refCurrent);
|
|
44
|
-
}, [widgetName, UCL
|
|
51
|
+
}, [widgetName, UCL]);
|
|
45
52
|
if (error) { throw error; }
|
|
46
53
|
if (shouldThrow) { throw new RenderFallbackSignal(); }
|
|
47
54
|
return <div ref={ref} />;
|
|
@@ -3,6 +3,8 @@ import React, { useCallback, useEffect, useRef } from 'react';
|
|
|
3
3
|
import { useIntl } from '@edx/frontend-platform/i18n';
|
|
4
4
|
import { Button, Image } from '@openedx/paragon';
|
|
5
5
|
import { Search } from '@openedx/paragon/icons';
|
|
6
|
+
import { useInView } from 'react-intersection-observer';
|
|
7
|
+
|
|
6
8
|
import { baseAppUrl } from 'data/services/lms/urls';
|
|
7
9
|
|
|
8
10
|
import emptyCourseSVG from 'assets/empty-course.svg';
|
|
@@ -16,6 +18,9 @@ const NoCoursesView = () => {
|
|
|
16
18
|
const { formatMessage } = useIntl();
|
|
17
19
|
const { courseSearchUrl } = reduxHooks.usePlatformSettingsData();
|
|
18
20
|
const viewCorrelationIdRef = useRef(window.crypto.randomUUID());
|
|
21
|
+
const hasViewEventFired = useRef(false);
|
|
22
|
+
|
|
23
|
+
const { ref: exploreCoursesRef, inView } = useInView({ triggerOnce: true });
|
|
19
24
|
|
|
20
25
|
const handleExploreCoursesViewed = useCallback(() => {
|
|
21
26
|
exploreCoursesViewedCohesion(viewCorrelationIdRef.current);
|
|
@@ -26,8 +31,11 @@ const NoCoursesView = () => {
|
|
|
26
31
|
};
|
|
27
32
|
|
|
28
33
|
useEffect(() => {
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
if (!hasViewEventFired.current && inView) {
|
|
35
|
+
handleExploreCoursesViewed();
|
|
36
|
+
hasViewEventFired.current = true;
|
|
37
|
+
}
|
|
38
|
+
}, [handleExploreCoursesViewed, inView]);
|
|
31
39
|
|
|
32
40
|
return (
|
|
33
41
|
<div
|
|
@@ -47,6 +55,7 @@ const NoCoursesView = () => {
|
|
|
47
55
|
onClick={handleExploreCoursesClick}
|
|
48
56
|
href={baseAppUrl(courseSearchUrl)}
|
|
49
57
|
iconBefore={Search}
|
|
58
|
+
ref={exploreCoursesRef}
|
|
50
59
|
>
|
|
51
60
|
{formatMessage(messages.exploreCoursesButton)}
|
|
52
61
|
</Button>
|
|
@@ -8,6 +8,13 @@ import { exploreCoursesViewedCohesion, exploreCoursesClickedCohesion } from '../
|
|
|
8
8
|
|
|
9
9
|
const courseSearchUrl = '/course-search-url';
|
|
10
10
|
|
|
11
|
+
jest.mock('react-intersection-observer', () => ({
|
|
12
|
+
useInView: jest.fn(() => ({
|
|
13
|
+
ref: jest.fn(),
|
|
14
|
+
inView: jest.fn(),
|
|
15
|
+
})),
|
|
16
|
+
}));
|
|
17
|
+
|
|
11
18
|
jest.mock('hooks', () => ({
|
|
12
19
|
reduxHooks: {
|
|
13
20
|
usePlatformSettingsData: jest.fn(() => ({
|