Skip to content

Commit 64c808d

Browse files
committed
Add to mangle
1 parent 8101042 commit 64c808d

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

mangle.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@
2828
"props": {
2929
"cname": 6,
3030
"props": {
31+
"$__persistentState": "__$p",
32+
"$_list": "__",
33+
"$_pendingSetup": "__h",
34+
"$_cleanup": "__c",
35+
"$_stateValue": "__",
36+
"$_args": "__H",
37+
"$_stored": "__s",
38+
"$_renderCallbacks": "__h",
39+
"$_parentDom": "__P",
40+
"$_skipEffects": "__s",
3141
"core: Node": "",
3242
"$_watched": "W",
3343
"$_unwatched": "Z",

packages/preact/src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ function queueSetupTasks(newQueueLength: number) {
467467
function flushSetup() {
468468
let component;
469469
while ((component = setupTasks.shift())) {
470-
if (!component.__persistentState) continue;
470+
if (!component.__persistentState || !component._parentDom) continue;
471471
try {
472472
component.__persistentState._pendingSetup.forEach(invokeCleanup);
473473
component.__persistentState._pendingSetup.forEach(invokeEffect);
@@ -527,11 +527,11 @@ function getState(index: number): HookState {
527527

528528
export function useStoreValueOnce<T>(factory: () => T): T {
529529
const state = getState(currentHookIndex++);
530-
if (!state._stored) {
530+
if (!state._stored || (options as any)._skipEffects) {
531531
state._stored = true;
532-
state._value = factory();
532+
state._stateValue = factory();
533533
}
534-
return state._value;
534+
return state._stateValue;
535535
}
536536

537537
export function useRef<T>(initialValue: T): { current: T } {
@@ -542,14 +542,14 @@ function useOnce(callback: () => void | (() => void)): void {
542542
const state = getState(currentHookIndex++);
543543
if (!state._executed) {
544544
state._executed = true;
545-
state._value = callback;
545+
state._stateValue = callback;
546546
currentComponent!.__persistentState._pendingSetup.push(state);
547547
}
548548
}
549549

550550
function invokeEffect(hook: HookState): void {
551-
if (hook._value) {
552-
hook._cleanup = hook._value() || undefined;
551+
if (hook._stateValue) {
552+
hook._cleanup = hook._stateValue() || undefined;
553553
}
554554
}
555555

packages/preact/src/internal.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ export interface AugmentedComponent extends Component<any, any> {
2828
_updater?: Effect;
2929
_updateFlags: number;
3030
__persistentState: SignalState;
31+
_parentDom?: Element | Text | null;
3132
}
3233

3334
export interface HookState {
3435
_executed?: boolean;
3536
_stored?: boolean;
36-
_value?: any;
37+
_stateValue?: any;
3738
_cleanup?: () => void;
3839
}
3940

0 commit comments

Comments
 (0)