@micromag/core 0.4.28 → 0.4.33

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 CHANGED
@@ -1020,15 +1020,17 @@ var usePlaybackMediaRef = function usePlaybackMediaRef() {
1020
1020
  media = _usePlaybackContext.media;
1021
1021
  var mediaRef = useRef(null);
1022
1022
 
1023
- // Cleanup: only clear if this ref owns the current media registration
1023
+ // Cleanup: clear media registration when this screen deactivates or unmounts.
1024
+ // Note: we cannot check mediaRef.current here because React clears callback refs
1025
+ // before running effect cleanups, so mediaRef.current is always null at this point.
1024
1026
  useEffect(function () {
1025
1027
  return function () {
1026
- if (active && mediaRef.current !== null && mediaRef.current === media) {
1028
+ if (active) {
1027
1029
  setMedia(null);
1028
1030
  setIsBackground(false);
1029
1031
  }
1030
1032
  };
1031
- }, [active, setMedia, setIsBackground, media]);
1033
+ }, [active, setMedia, setIsBackground]);
1032
1034
 
1033
1035
  // Register media with context when active and no media is registered
1034
1036
  useEffect(function () {
package/lib/contexts.js CHANGED
@@ -1020,15 +1020,17 @@ var usePlaybackMediaRef = function usePlaybackMediaRef() {
1020
1020
  media = _usePlaybackContext.media;
1021
1021
  var mediaRef = React.useRef(null);
1022
1022
 
1023
- // Cleanup: only clear if this ref owns the current media registration
1023
+ // Cleanup: clear media registration when this screen deactivates or unmounts.
1024
+ // Note: we cannot check mediaRef.current here because React clears callback refs
1025
+ // before running effect cleanups, so mediaRef.current is always null at this point.
1024
1026
  React.useEffect(function () {
1025
1027
  return function () {
1026
- if (active && mediaRef.current !== null && mediaRef.current === media) {
1028
+ if (active) {
1027
1029
  setMedia(null);
1028
1030
  setIsBackground(false);
1029
1031
  }
1030
1032
  };
1031
- }, [active, setMedia, setIsBackground, media]);
1033
+ }, [active, setMedia, setIsBackground]);
1032
1034
 
1033
1035
  // Register media with context when active and no media is registered
1034
1036
  React.useEffect(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/core",
3
- "version": "0.4.28",
3
+ "version": "0.4.33",
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": "1b14d4403eb5decff05346870eb849a96f636604",
164
+ "gitHead": "8c44ced53cad6b575c85b556eb246f477cfb4933",
165
165
  "types": "es/index.d.ts"
166
166
  }