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