@prefresh/core
Advanced tools
Comparing version 1.0.0 to 1.1.0
# @prefresh/core | ||
## 1.1.0 | ||
### Minor Changes | ||
- [`ac7c5d1`](https://github.com/JoviDeCroock/prefresh/commit/ac7c5d150bcbb9cea40060549b31a2ed06fcc5dc) [#202](https://github.com/JoviDeCroock/prefresh/pull/202) Thanks [@JoviDeCroock](https://github.com/JoviDeCroock)! - Cleanup effects when resetting hooks state | ||
## 1.0.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@prefresh/core", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "src/index.js", | ||
@@ -5,0 +5,0 @@ "exports": { |
@@ -25,2 +25,4 @@ // Options for Preact. | ||
const forbiddenEffectFields = ['__', '__H']; | ||
function sign(type, key, forceReset, getCustomHooks, status) { | ||
@@ -99,2 +101,32 @@ if (type) { | ||
if (resetHookState) { | ||
if ( | ||
vnode[VNODE_COMPONENT][COMPONENT_HOOKS] && | ||
vnode[VNODE_COMPONENT][COMPONENT_HOOKS][EFFECTS_LIST] | ||
) { | ||
vnode[VNODE_COMPONENT][COMPONENT_HOOKS][EFFECTS_LIST].forEach( | ||
effect => { | ||
const possibleCleanupKeys = Object.keys(effect).filter( | ||
key => !forbiddenEffectFields.includes(key) | ||
); | ||
possibleCleanupKeys.forEach(key => { | ||
if (typeof effect[key] == 'function') effect[key](); | ||
}); | ||
} | ||
); | ||
} | ||
if (vnode[VNODE_COMPONENT].__h) { | ||
vnode[VNODE_COMPONENT].__h.forEach(possibleEffect => { | ||
if (typeof possibleEffect === 'object') { | ||
const possibleCleanupKeys = Object.keys(possibleEffect).filter( | ||
key => !forbiddenEffectFields.includes(key) | ||
); | ||
possibleCleanupKeys.forEach(key => { | ||
if (typeof possibleEffect[key] == 'function') | ||
possibleEffect[key](); | ||
}); | ||
} | ||
}); | ||
} | ||
vnode[VNODE_COMPONENT][COMPONENT_HOOKS] = { | ||
@@ -101,0 +133,0 @@ [HOOKS_LIST]: [], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14382
257