@micromag/core 0.4.28 → 0.4.30
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/es/contexts.js +7 -2
- package/lib/contexts.js +7 -2
- package/package.json +2 -2
package/es/contexts.js
CHANGED
|
@@ -1019,16 +1019,21 @@ var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
|
1019
1019
|
setIsBackground = _usePlaybackContext.setIsBackground,
|
|
1020
1020
|
media = _usePlaybackContext.media;
|
|
1021
1021
|
var mediaRef = useRef(null);
|
|
1022
|
+
// Track latest media value in a ref so the cleanup function can check ownership
|
|
1023
|
+
// without having media in the dependency array (which would cause cleanup to run
|
|
1024
|
+
// on every registration, immediately clearing the media that was just set).
|
|
1025
|
+
var mediaValueRef = useRef(media);
|
|
1026
|
+
mediaValueRef.current = media;
|
|
1022
1027
|
|
|
1023
1028
|
// Cleanup: only clear if this ref owns the current media registration
|
|
1024
1029
|
useEffect(function () {
|
|
1025
1030
|
return function () {
|
|
1026
|
-
if (active && mediaRef.current !== null && mediaRef.current ===
|
|
1031
|
+
if (active && mediaRef.current !== null && mediaRef.current === mediaValueRef.current) {
|
|
1027
1032
|
setMedia(null);
|
|
1028
1033
|
setIsBackground(false);
|
|
1029
1034
|
}
|
|
1030
1035
|
};
|
|
1031
|
-
}, [active, setMedia, setIsBackground
|
|
1036
|
+
}, [active, setMedia, setIsBackground]);
|
|
1032
1037
|
|
|
1033
1038
|
// Register media with context when active and no media is registered
|
|
1034
1039
|
useEffect(function () {
|
package/lib/contexts.js
CHANGED
|
@@ -1019,16 +1019,21 @@ var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
|
1019
1019
|
setIsBackground = _usePlaybackContext.setIsBackground,
|
|
1020
1020
|
media = _usePlaybackContext.media;
|
|
1021
1021
|
var mediaRef = React.useRef(null);
|
|
1022
|
+
// Track latest media value in a ref so the cleanup function can check ownership
|
|
1023
|
+
// without having media in the dependency array (which would cause cleanup to run
|
|
1024
|
+
// on every registration, immediately clearing the media that was just set).
|
|
1025
|
+
var mediaValueRef = React.useRef(media);
|
|
1026
|
+
mediaValueRef.current = media;
|
|
1022
1027
|
|
|
1023
1028
|
// Cleanup: only clear if this ref owns the current media registration
|
|
1024
1029
|
React.useEffect(function () {
|
|
1025
1030
|
return function () {
|
|
1026
|
-
if (active && mediaRef.current !== null && mediaRef.current ===
|
|
1031
|
+
if (active && mediaRef.current !== null && mediaRef.current === mediaValueRef.current) {
|
|
1027
1032
|
setMedia(null);
|
|
1028
1033
|
setIsBackground(false);
|
|
1029
1034
|
}
|
|
1030
1035
|
};
|
|
1031
|
-
}, [active, setMedia, setIsBackground
|
|
1036
|
+
}, [active, setMedia, setIsBackground]);
|
|
1032
1037
|
|
|
1033
1038
|
// Register media with context when active and no media is registered
|
|
1034
1039
|
React.useEffect(function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.30",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -161,6 +161,6 @@
|
|
|
161
161
|
"access": "public",
|
|
162
162
|
"registry": "https://registry.npmjs.org/"
|
|
163
163
|
},
|
|
164
|
-
"gitHead": "
|
|
164
|
+
"gitHead": "7df8ed5c6b5f3096a94f2bb952858e73227e12bb",
|
|
165
165
|
"types": "es/index.d.ts"
|
|
166
166
|
}
|