@@ -270,6 +270,7 @@ hook(OptionsTypes.DIFFED, (old, vnode) => {
270
270
component . __persistentState &&
271
271
component . __persistentState . _pendingSetup . length
272
272
) {
273
+ console . log ( "f" , component . __persistentState . _pendingSetup ) ;
273
274
queueSetupTasks ( setupTasks . push ( component ) ) ;
274
275
}
275
276
}
@@ -467,7 +468,8 @@ function queueSetupTasks(newQueueLength: number) {
467
468
function flushSetup ( ) {
468
469
let component ;
469
470
while ( ( component = setupTasks . shift ( ) ) ) {
470
- if ( ! component . __persistentState ) continue ;
471
+ console . log ( "flushSetup" , component . __P , component . __persistentState ) ;
472
+ if ( ! component . __persistentState || ! component . __P ) continue ;
471
473
try {
472
474
component . __persistentState . _pendingSetup . forEach ( invokeCleanup ) ;
473
475
component . __persistentState . _pendingSetup . forEach ( invokeEffect ) ;
@@ -527,11 +529,11 @@ function getState(index: number): HookState {
527
529
528
530
export function useStoreValueOnce < T > ( factory : ( ) => T ) : T {
529
531
const state = getState ( currentHookIndex ++ ) ;
530
- if ( ! state . _stored ) {
532
+ if ( ! state . _stored || ( options as any ) . _skipEffects ) {
531
533
state . _stored = true ;
532
- state . _value = factory ( ) ;
534
+ state . _stateValue = factory ( ) ;
533
535
}
534
- return state . _value ;
536
+ return state . _stateValue ;
535
537
}
536
538
537
539
export function useRef < T > ( initialValue : T ) : { current : T } {
@@ -542,14 +544,15 @@ function useOnce(callback: () => void | (() => void)): void {
542
544
const state = getState ( currentHookIndex ++ ) ;
543
545
if ( ! state . _executed ) {
544
546
state . _executed = true ;
545
- state . _value = callback ;
547
+ state . _stateValue = callback ;
546
548
currentComponent ! . __persistentState . _pendingSetup . push ( state ) ;
547
549
}
548
550
}
549
551
550
552
function invokeEffect ( hook : HookState ) : void {
551
- if ( hook . _value ) {
552
- hook . _cleanup = hook . _value ( ) || undefined ;
553
+ console . log ( "invokeEffect" , hook ) ;
554
+ if ( hook . _stateValue ) {
555
+ hook . _cleanup = hook . _stateValue ( ) || undefined ;
553
556
}
554
557
}
555
558
0 commit comments