Teact: Fix missing layout effects after first render (follow-up)
This commit is contained in:
parent
cc9a7efbf5
commit
9a75d79705
@ -19,6 +19,7 @@ import {
|
||||
unmountComponent,
|
||||
isFragmentElement,
|
||||
runImmediateEffects,
|
||||
willRunImmediateEffects,
|
||||
} from './teact';
|
||||
import { DEBUG } from '../../config';
|
||||
import { addEventListener, removeAllDelegatedListeners, removeEventListener } from './dom-events';
|
||||
@ -57,7 +58,9 @@ function render($element: VirtualElement | undefined, parentEl: HTMLElement) {
|
||||
const $head = headsByElement.get(parentEl)!;
|
||||
const $newElement = renderWithVirtual(parentEl, $head.children[0], $element, $head, 0);
|
||||
|
||||
queueMicrotask(runImmediateEffects);
|
||||
if (!willRunImmediateEffects()) {
|
||||
runImmediateEffects();
|
||||
}
|
||||
|
||||
$head.children = $newElement ? [$newElement] : [];
|
||||
|
||||
|
||||
@ -307,8 +307,11 @@ let pendingEffects = new Map<string, Effect>();
|
||||
let pendingCleanups = new Map<string, EffectCleanup>();
|
||||
let pendingLayoutEffects = new Map<string, Effect>();
|
||||
let pendingLayoutCleanups = new Map<string, EffectCleanup>();
|
||||
let areImmediateEffectsPending = false;
|
||||
|
||||
const runUpdatePassOnRaf = throttleWithRafFallback(() => {
|
||||
areImmediateEffectsPending = true;
|
||||
|
||||
idsToExcludeFromUpdate = new Set();
|
||||
|
||||
const instancesToUpdate = Array
|
||||
@ -335,9 +338,14 @@ const runUpdatePassOnRaf = throttleWithRafFallback(() => {
|
||||
forceUpdateComponent(instance);
|
||||
});
|
||||
|
||||
areImmediateEffectsPending = false;
|
||||
runImmediateEffects();
|
||||
});
|
||||
|
||||
export function willRunImmediateEffects() {
|
||||
return areImmediateEffectsPending;
|
||||
}
|
||||
|
||||
export function runImmediateEffects() {
|
||||
const currentLayoutCleanups = pendingLayoutCleanups;
|
||||
pendingLayoutCleanups = new Map();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user